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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With