Cannot stop or restart docker container

When I try to stop or restart the docker container, I get the following error message:

$ docker restart 5ba0a86f36ea Error response from daemon: Cannot restart container 5ba0a86f36ea: [2] Container does not exist: container destroyed Error: failed to restart containers: [5ba0a86f36ea] 

But when I started

 $ docker logs -f 5ba0a86f36ea 

I see the logs, so the container clearly exists. Any ideas?

Edit:

Sorry, I forgot to mention this:

When I start docker ps -a , I see the container in working condition. However, the application inside it does not work correctly, so I want to restart it or just get a new version of this application on the Internet. But when I cannot stop and remove the container, I also cannot start and start a new application that will listen on the same port.

+38
docker
source share
6 answers

This looks like docker / docker / issues / 12738 , using docker 1.6 or 1.7:

Some containers cannot stop normally, and restart

We often encounter this problem in our user hosts when upgrading from 1.5.0 to 1.6.0.
After the upgrade, some containers cannot be stopped (providing 500 Server Error: Internal Server Error ("Cannot stop container xxxxx: [2] Container does not exist: container destroyed" )) or forced destruction (providing 500 Server Error: Internal Server Error ("Could not kill running container, cannot remove - [2] Container does not exist: container destroyed" )). Processes are still running on the host.
Sometimes it works after restarting the docker daemon.

There are some workarounds:

I tried all the remote API calls for this unkillable container, and here are the results:

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

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

Or:

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

 $ boot2docker stop $ boot2docker start $ docker rm -f 1f061139ba04 
+22
source share

boot2docker not on my machine. So, I found something that worked for me.

 $ sudo systemctl restart docker.socket docker.service $ docker rm <container id> 

Check if it works for you.

+47
source share

Worth knowing:

If you use an ENTRYPOINT script ... the script will work with shebang

 #!/bin/bash -x 

But stop the container from stopping with

 #!/bin/bash -xe 
+9
source share

All docker start | restart | stop | rm --force | kill start | restart | stop | rm --force | kill 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, this may not be an option. What you can do is:

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

The output contains:

 <<user>><<process id>> 

Then complete the process associated with the container as follows:

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

This will kill the container, and you can launch a new container with the desired image.

+1
source share

If all else fails, you can remove the Docker desktop on Windows and Mac to stop the container.

I killed all the docker desktop processes before ... but I don't know if this is necessary.

0
source share

Enjoy

sudo aa-remove-unknown

This is what worked for me.

0
source share

All Articles