a year ago
How to restart all running docker containers?
The reason we had to look into this is because we wanted to setup our own SMTP email server in a docker and having tried a couple of options we ended up with mailcow. Funny name but the only choice with no SPF and DKIM issues. However it creates a lot of docker containers to get up and running. Not a bad thing until you have to reset all cache and figure out how to restart all docker containers. Now that was our use case, your use case might be completely different but what to do next is the same.
First see which containers are running.
A simple command to do that is.
Do you only have docker container running?
If so, to restart that individual container you can run
docker restart <container_id>
If you have multiple docker containers running which is why you probably ended up here try running
docker ps -q | xargs docker restart
If that doesn't work for any reason, also try
docker restart $(docker ps -q)
Love working with docker. Checkout docker jobs
Did that work for you?