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.

  • How to create a docker base image?
  • Using Docker for development and sharing dependencies for features such as IDE auto-completion
  • Install shipyard on existing docker swarm
  • Docker Compose - symlink in deployment
  • POSIX locale, UnicodeDecodeError
  • How to mount host codes to container in docker?
  • 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).

  • How to set the remote API version for docker client?
  • Is it possible to get terminal notifications in OSX through a docker container?
  • sublime sftp connects to wrong container
  • jenkins docker plugin job “Permission denied” error
  • Send a file via SFTP to a Docker Container
  • Debug Symfony2 in Docker with PhpStorm and Xdebug
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.