Docker pause / unpause groups of containers based on Image

Patrick

Administrator
Staff member
Dec 21, 2010
11,815
4,767
113
I have done this with scripts based on -name tags that I give containers at runtime. Does anyone have a bash/ python script that lets you pause/unpause a container or all containers using an image?

For example, if you had a NGINX container and wanted to pause all of the 1.12 containers in a cluster (eg using nginx:alpine).
 

nitrobass24

Moderator
Dec 26, 2010
1,082
126
63
TX
Can do this with a single command

Code:
docker stop $(docker ps -a -q --filter=name=nginx:alpine)
EDIT - I guess you asked for "Pause", same logic applies.

Code:
docker pause $(docker ps -a -q --filter=name=nginx:alpine)
 
  • Like
Reactions: Patrick

Patrick

Administrator
Staff member
Dec 21, 2010
11,815
4,767
113
Thanks!

I am trying to automate the up/ down of my nvidia-docker containers that are not managed with Rancher.