Docker pause / unpause groups of containers based on Image

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

Patrick

Administrator
Staff member
Dec 21, 2010
12,513
5,802
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,087
131
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
12,513
5,802
113
Thanks!

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