Ranjith's
Ranjith's

Reputation: 4730

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

Upvotes: 154

Views: 324920

Answers (9)

Gencay Tekin
Gencay Tekin

Reputation: 21

An other way docker ps -q | xargs docker restart

Upvotes: 0

WagnerVF
WagnerVF

Reputation: 1

start last 5 containers

 docker start $(docker ps -n 5 -q)

Upvotes: -1

thefourCraft
thefourCraft

Reputation: 63

To restart all the online docker containers

docker restart $(docker ps -a -q -f status=healthy)

To start all the stopped containers:

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

Other status options can be:

created, restarting, running, removing, paused, exited, dead.

Upvotes: 4

Andrey Romashin
Andrey Romashin

Reputation: 3653

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.

Upvotes: 333

naveen chander
naveen chander

Reputation: 21

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

Upvotes: 0

Hitesh Kumar
Hitesh Kumar

Reputation: 313

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)

Upvotes: 13

benjaminz
benjaminz

Reputation: 3228

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/

Upvotes: 30

Cepr0
Cepr0

Reputation: 30279

To start only stopped containers:

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

(On windows it works in Powershell).

Upvotes: 31

bohr
bohr

Reputation: 1316

For me its now :

docker restart $(docker ps -a -q)

Upvotes: 117

Related Questions