Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot stop or restart a docker container

Tags:

docker

When trying to stop or restart a docker container I'm getting 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 run

$ docker logs -f 5ba0a86f36ea 

I can see the logs, so obviously the container does exist. Any ideas?

Edit:

sorry, I forgot to mention this:

When I run docker ps -a I see the container as up and running. However the application inside it is malfunctioning so I want to restart it, or just get a fresh version of that application online. But when I can't stop and remove the container, I also can't get a new application up and running, which would be listening to the same port.

like image 549
peter Avatar asked Jul 12 '15 08:07

peter


People also ask

How do you stop a docker container that won't stop?

docker rm -f The final option for stopping a running container is to use the --force or -f flag in conjunction with the docker rm command. Typically, docker rm is used to remove an already stopped container, but the use of the -f flag will cause it to first issue a SIGKILL.

How do I force restart a docker container?

Using --restart unless-stopped tells Docker to always restart the command, no matter what the exit code of the command was. This way, you can have your application check its health, and if necessary use exit(1) or something similar to shutdown.

How do I kill a running docker container?

The docker kill subcommand kills one or more containers. The main process inside the container is sent SIGKILL signal (default), or the signal that is specified with the --signal option. You can reference a container by its ID, ID-prefix, or name.


1 Answers

I couldn't locate boot2docker in my machine. So, I came up with something that worked for me.

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

Check if it helps you as well.

like image 200
Abhishek Kashyap Avatar answered Oct 08 '22 23:10

Abhishek Kashyap