Stopping paused Docker containers

In my application consisting of several containers, I pause containers which are currently not needed. When they are needed again, I unpause them. This works fine.

However, if something goes wrong in one of the running containers(container exits with exit code != 0), docker-compose(which I am also using) tries to stop all the other containers. If a container is paused, it cannot be stopped or killed.

  • docker commit the changes,but start error
  • How to connect to local Docker on Windows with Eclipse?
  • How run Symfony commands in background Docker
  • Cadvisor -Failed to get RecentStats :unable to find data for container /system.slice/docker
  • Running many docker instances on Google cloud with different command-line parameters
  • CPP Rest SDK http_listener throws exception in nano server (in a Docker container)
  • A small example to illustrate what happens. (all of these commands are automated in my case)

    docker start cd1d8ad01f56
    docker pause cd1d8ad01f56
    docker stop cd1d8ad01f56
    Error response from daemon: Cannot stop container cd1d8ad01f56: 
     Container cd1d8ad01f56c695a598e168e2eacdcd20a5231b9240029db1579bc0f1dcb903 
     is paused. Unpause the container before stopping
    Error: failed to stop containers: [cd1d8ad01f56]

    I want the containers to be stopped, even if they are paused.

    Solutions I thought of:

    • First unpause every sleeped container, then stop or kill it. This is an unsuitable solution that requires manual work. But it works…
      I could write a script that looks for paused containers and then unpauses and kills them. But I want for compose to just kill all the other stuff and be done with it. I do not want to have to issue another command to execute my script.

    • Is there a way to specify the code of a container that exits(i.e. tell it to unpause other containers)? So that the containers are not sleeped when trying to stop them.

    First unpausing every sleeped container, to then stop or kill it is tedious work, which I would like to automate. I am working in a test environment and do not care how the containers shutdown. I just want them to end together with the failed container(s).

  • Meaning of docker-compose exit code?
  • docker doesn't get the latest images with tag latest
  • Docker-compose: Database is uninitialized
  • How to configure Vagrant box filesystem?
  • ssh: Could not resolve hostname (Docker, gitlab-ce)
  • Strategy for versioning Docker images linked to other contains via docker compose
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.