Command for Restarting All Running Docker Containers?

Command for Restarting All Running Docker Containers?

How to restart all running docker containers? Mainly looking for a shortcut instead of doing

docker restart containerid1 containerid2

6 Answers

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.

6

For me its now :

docker restart $(docker ps -a -q)
3

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:

1

To start only stopped containers:

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

(On windows it works in Powershell).

To start all the containers:

  docker restart $(docker ps -a -q)

Use sudo if you don't have permission to perform this:

sudo docker restart $(sudo docker ps -a -q)

To start multiple containers with the only particular container ids $ docker restart container-id1 container-id2 container-id3 ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.