Docker pause / unpause groups of containers based on Image

Discussion in 'Docker and Containers' started by Patrick, May 24, 2017.

  1. Patrick

    Patrick Administrator
    Staff Member

    Joined:
    Dec 21, 2010
    Messages:
    10,916
    Likes Received:
    3,847
    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).
     
    #1
  2. nitrobass24

    nitrobass24 Moderator

    Joined:
    Dec 26, 2010
    Messages:
    1,070
    Likes Received:
    125
    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)
     
    #2
    Patrick likes this.
  3. Patrick

    Patrick Administrator
    Staff Member

    Joined:
    Dec 21, 2010
    Messages:
    10,916
    Likes Received:
    3,847
    Thanks!

    I am trying to automate the up/ down of my nvidia-docker containers that are not managed with Rancher.
     
    #3
Similar Threads: Docker pause
Forum Title Date
Docker and Containers I am confused: Can someone summarize what linux docker is ? Feb 11, 2018
Docker and Containers USB Docker image Dec 13, 2017
Docker and Containers cpuset-cpus to Constrain Docker Containers Nov 4, 2017
Docker and Containers Best way to stop all docker containers on a host Oct 11, 2017
Docker and Containers Docker Multiple IDs found with provided prefix Aug 1, 2017

Share This Page