Command for restarting all running docker containers?

For me its now :

docker restart $(docker ps -a -q)

To start only stopped containers:

docker start $(docker ps -a -q -f status=exited)

(On windows it works in Powershell).


If you have docker-compose, all you need to do is:

docker-compose restart 

And you get nice print out of the container's name along with its status of the restart (done/error)

Here is the official guide for installing: https://docs.docker.com/compose/install/


Just run

docker restart $(docker ps -q)

Update

For restarting ALL (stopped and running) containers use docker restart $(docker ps -a -q) as in answer lower.