Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 317
Ranjith's Avatar asked Jul 06 '16 10:07

Ranjith's


People also ask

How can you restart all docker containers running on a server?

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

How do I start all docker containers in one command?

If you mean to create multiple containers at the same time then you will have to make use of docker-compose. This will startup any stopped containers.

How do you restart a whole docker?

The Docker Engine must reload configuration information if any changes are made to the Docker configuration. To do this, you must restart the docker service. If you edit the /etc/sysconfig/docker configuration file while the docker service is running, you must restart the service to make the changes take effect.

How do I restart my docker container every day?

As a reference, I use 30 1 * * * docker restart container_name to restart a container every day at 01:30 at night. You can get the container_name by running docker ps .


1 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.

like image 186
Andrey Romashin Avatar answered Sep 21 '22 05:09

Andrey Romashin