I cannot stop, remove or kill my docker container. Commands given below with their respective error messages:
1. docker stop <container-id>
2. docker kill <container-id>
3. docker rm <container-id>
I get
1. Error response from daemon: cannot stop container: <container-id>: tried to kill container, but did not receive an exit event
2. Error response from daemon: cannot kill container: <container-id>: tried to kill container, but did not receive an exit event
3. Error response from daemon: You cannot remove a running container <container-id>. Stop the container before attempting removal or force remove
Same error messages if i prefix everything with sudo and also the same messages if I run all of commands above with --force. How do I solve this? It seems like I can't stop, kill or remove the container because it does not "receive an exit event". Nothing here helps: Error response from daemon: cannot stop container - signaling init process caused "permission denied" .
I used wilon's answer from https://forums.docker.com/t/restart-docker-from-command-line/9420/2
I ran killall Docker && open /Applications/Docker.app
Once that was done, I ran docker-compose down and all containers stopped as expected.
Some of the solutions that you can try:
Restart the docker service: sudo systemctl restart docker.service
Restart the Host Machine
Enter inside the container docker exec -it ContainerName /bin/bash and then Kill the container kill 1
You can disable the apparmor service so first check the status sudo apparmor_status then disable it sudo systemctl disable apparmor then teardown the apparmor sudo service apparmor teardown. Now check the status again sudo apparmor_status
I had the same when running docker-compose down for one of my containers, everything worked fine again after running docker-compose restart.
I didn't need to restart whole Docker service.
"Docker p"s shows 1 running container. The command "docker ps --filter status=running" shows the same process.
When trying to stop the container, I get the identification but nothing happens. The container is still running.
When I performing a 'docker kill id' I get:
Error response from daemon: Cannot kill container: xyz: Container
2f-etc is not running
I cannot perform a 'docker container rm name' because of this message:
Error response from daemon: driver "overlay2" failed to remove root
filesystem for
2f-etc:
remove
/var/lib/docker/overlay2/0877e30fd3a98f46b981827b52aec02a7004649e2a9c01c72e38cc8de5b309b0/diff/tmp/hsperfdata_root/5:
read-only file system
How to stop / kill that container?
What do I know more:
It may be that I stopped my computer without stopping the container. I will take care ;-)
I noticed also that creating a new image with 'docker build -t newname .' is failing because: Error response from daemon: mkdir /var/lib/docker/tmp/docker-builder471922504: read-only file system
Restart docker is simple but global solution. In my case I needed to keep other containers working without stop and the solution of #juanlumn helped me, which is docker container rm -f name (it removes container).
As #Aderemi Dayo suggested - a restart of the Docker machine suffices.
Sometimes docker restart doesn't work, so you may have to individually run docker stop & docker start. Thereafter use the docker container rm <container> command to remove.
I have tried
docker kill name_of_the_process
But the error is
Error response from daemon: Cannot kill container: name_of_the_container: Container name_of_the_container is not running
There are a lot of processes when I run docker ps -a, how do I kill those, they are stopped but not killed
A stopped container is killed. There is no running process, but there is a writable container specific filesystem and some metadata remaining which allows you to debug the stopped container and restart it. To remove that, use docker container rm (or the former alias docker rm) to remove the stopped container data. e.g.
docker container ls -aqf status=exited | xargs docker container rm
docker ps Shows you the running containers. If you add the -a flag it will print out all the containers, even the ones not running.
You can not "stop" a non-running container, it is already stopped.
You can find more information here: https://docs.docker.com/engine/reference/commandline/ps/
If you wish to remove the container, you can remove it by id or name. The command for that is docker rm <id/name>
Tip: You can use the first few chars of the id to identify the container, you don't need the whole id
System version: ubuntu 14.04
Docker version: 1.0.1, build 990021a
I am new to docker, I try the command
docker run -p 5000:5000 registry
But it takes a long time. And I feel it is too long. So I pressed ctrl + c to stop this operation. Then, I tried
docker pull registry
But it occured some errors. I worried about it so i restart the system. Then I input docker images. There are many images named none, and when I try to delete it, it will return an error. See the picture.
Picture
You might have encountered this bug: https://github.com/Strider-CD/strider-dockerfile/issues/7
One of the comments says that
You could always kill the docker daemon...
If stopping the daemon (service docker stop) you can kill it either with pkill docker or by looking up the PID from ps aux | grep docker and then killing the process with kill -9 <PID>.
Does this help you?
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.
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.
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.
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
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
Enjoy
sudo aa-remove-unknown
This is what worked for me.
Check if there is any zombie process using "top" command.
docker ps | grep <<container name>>
Get the container id.
ps -ef | grep <<container id>>
ps -ef|grep defunct | grep java
And kill the container by Parent PID .
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.
If you're on a Mac and try this via Terminal: Use killall Docker to quit Docker.
Restart it in the Applications folder or with open /Applications/Docker.app.
Subsequently you can run a docker rm <id> for the concerned container.
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.
Ubuntu
Stop the container by using its system process ID.
Get the main process ID using:
docker inspect -f '{{.State.Pid}}' container-id
This will return an id as ´25430´.
Kill this with the command
sudo kill -9 25430
in my case, i couldn't delete container created with nomad jobs,
there's no output for the docker logs <ContainerID> and, in general, it looks like frozen.
until now the solution is: sudo service docker restart, may someone suggest better one?
i forgot that i had made the container start as a system service.
so if i stopped or killed the container, the service would bring it back.
if you are using systemctl, you can list all the running services with systemctl | grep running and find the name of the service.
then use
sudo systemctl disable <your_service_name> to stop it.
If you're on Ubuntu, make sure docker-compose isn't installed as a snap. This will cause all kinds of random issues, including the above.
Remove the snap:
sudo snap remove docker-compose
And install manually from the compose repository:
Docker compose installation instruction
Sometimes this is caused by problem of the docker daemon.
I solved the problem by restarting the docker service.
On Linux:
systemctl restart docker
In my case, docker rm $(docker ps -aq) works for me.