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.

  • Securty options in embeded linux?
  • How to dockerize two applications talking to each other via a http server?
  • docker-compose stop not working after docker-compose -p <name> up
  • Building Dockerfile fails when touching a file after a mkdir
  • docker mysql restoring dump files
  • django + nginx in docker containers: can not upload any file with forms
  • 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).

  • Docker Hub timeout in automated build
  • How to reload environment variables in docker-compose container with minimum downtime?
  • docker - change default login user
  • Docker daemon fails to start: inotify_add_watch: no such file or directory
  • which ports should be exposed in a docker container for apache ignite?
  • Why is git clone failing when I build an image from a dockerfile?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.