Cannot stop or restart a docker container

前端 未结 10 1079
别跟我提以往
别跟我提以往 2021-01-30 01:54

When trying to stop or restart a docker container I\'m getting the following error message:

$ docker restart 5ba0a86f36ea
Error response from daemon: Cannot rest         


        
相关标签:
10条回答
  • 2021-01-30 02:38

    All the docker: start | restart | stop | rm --force | kill commands may not work if the container is stuck. You can always restart the docker daemon. However, if you have other containers running, that may not be the option. What you can do is:

    ps aux | grep <<container id>> | awk '{print $1 $2}'
    

    The output contains:

    <<user>><<process id>>
    

    Then kill the process associated with the container like so:

    sudo kill -9 <<process id from above command>>
    

    That will kill the container and you can start a new container with the right image.

    0 讨论(0)
  • 2021-01-30 02:38

    I had the same problem on a windows host machine and none of the other options here worked for me. I ended up just needing to delete the physical container folder, which was located here:

    C:\ProgramData\Docker\containers\[container guid]
    

    I had stopped the docker service first just to be safe and when I restarted it, the broken containers were now gone and I was able to create new ones. I suspect the same will work on a linux host machine, but I do not know where the container folders are kept on that OS.

    0 讨论(0)
  • 2021-01-30 02:40

    If you're on Ubuntu, make sure docker-compose isn't installed as snap. This will cause all kinds of random issues, including the above.

    Remove the snap:

    sudo snap remove docker-compose
    

    And install manually from compose repository:

    Docker compose installation instruction

    0 讨论(0)
  • 2021-01-30 02:44

    For anyone on a Mac who has Docker Desktop installed. I was able to just click the tray icon and say Restart Docker. Once it restarted was able to delete the containers.

    0 讨论(0)
  • 2021-01-30 02:46

    That looks like docker/docker/issues/12738, seen with docker 1.6 or 1.7:

    Some container fail to stop properly, and the restart

    We are seeing this issue a lot in our users hosts when they upgraded from 1.5.0 to 1.6.0.
    After the upgrade, some containers cannot be stopped (giving 500 Server Error: Internal Server Error ("Cannot stop container xxxxx: [2] Container does not exist: container destroyed")) or forced destroyed (giving 500 Server Error: Internal Server Error ("Could not kill running container, cannot remove - [2] Container does not exist: container destroyed")). The processes are still running on the host.
    Sometimes, it works after restarting the docker daemon.

    There are some workarounds:

    I've tried all remote API calls for that unkillable container and here are results:

    • json, stats, changes, top, logs returned valid responses
    • stop, pause, wait, kill reported 404 (!)

    After I finished with remote API, I double-checked docker ps (the container was still there), but then I retried docker kill and it worked! The container got killed and I could remove it.

    Or:

    What worked was to restart boot2docker on my host. Then docker rm -f

    $ boot2docker stop
    $ boot2docker start
    $ docker rm -f 1f061139ba04
    
    0 讨论(0)
  • 2021-01-30 02:49

    Worth knowing:

    If you are running an ENTRYPOINT script ... the script will work with the shebang

    #!/bin/bash -x
    

    But will stop the container from stopping with

    #!/bin/bash -xe
    
    0 讨论(0)
提交回复
热议问题