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
Related
I am trying to remove container but when i run docker-compose rm ,runs fine but when i run docker ps then again it shows container:
root#datafinance:/tmp# docker-compose rm
Going to remove tmp_zookeeper_1_31dd890a1cbf
Are you sure? [yN] y
Removing tmp_zookeeper_1_31dd890a1cbf ... done
root#datafinance:/tmp# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
03b08e4ef0b3 confluentinc/cp-zookeeper:latest "/etc/confluent/dockā¦" 14 hours ago Up 14 hours docker_c_zookeeper_1_7c953dce7d69
Use docker-compose ps, it will show the container which only launched by docker-compose up. If it shows there is no container, then this means this container was not launched by this docker-compose.yaml.
And Error starting userland proxy: listen tcp 0.0.0.0:32181: bind: address already in use' means the port 32181 is occupied either by other docker container or other process. You could use docker rm -f $(docker ps -qa) to delete all containers or more you can use netstat -oanltp | grep 32181 to find which process really occupy 32181.
Finally, if for any reason you did not able to delete container as you said, you can just use service docker restart or systemctl restart docker to make all container down. Then repeat above docker rm xxx.
With above steps, you can use docker compose up -d to use your service now.
try this :
docker rm -f 03b08e4ef0b3
DANGER
you may also try this, but be aware that will delete everything (Containers, Images, Networks, ....)
docker system prune -a -f
when all not helped your last resort is to restart Docker daemon
service docker restart
and then repeat the steps...
I think what you are looking for is :
docker-compose down
which removes the containers after stopping them according to this.
According to this, docker-compose rm removes the "stopped" containers. If your container(s) are running, I think it won't remove to prevent accidents.
When I launch docker, it launch by default a few containers that I have build in the past.(I've use docker-compose at the time, but deleted the repo since)
I kill them, but each time i restart docker, they are back.
What can I do ?
I know there is something like "docker system prune",
but I would like to delete the less possible .
You can try running docker ps -a to get a list of all containers including the ones which are not running but stopped.
You can then docker rm each container you do not wish to start on each docker restart.
Use docker ps to see what containers are running.
Use this command to kill/stop all running containers.
docker rm $(docker ps -a -q)
Use docker images to get list of all images.
Use docker rmi <image_id> to delete desired image.
when calling docker ps the list is empty, although I got an id:
(dcbb6aeaa06ba43fcb.....)
My steps:
Step 1: I created an image (imagekommando) of an running js.file:
Step 2: I created a container (in background) based on my image
docker run -d --name containerkommando imagekommando
I got an id! (container-id??)
Step 3: But docker ps shows empty list:
But when I repeat Step 2, I'm told, that the container (containerkommando) already exists:
docker run -d --name containerkommando imagekommando
Could you help me, understanding the logic behind?
And how can I get the container running (by ID)?
That means that the docker container exited with an error but clean up is required. With --rm option you can tell the docker to remove the container when the container has exited.
docker run --rm .....
Also to check the reason for the container exiting...you can use
docker logs <container_id>
What probably takes place here:
docker run ... creates and starts your container
your container exits
docker ps doesn't list stopped containers (default shows just running), so it made you think that it's not there.
docker run ... fails because you are trying to create and run a container with a name that already exists.
Further reading:
What are the possible states for a docker container?
Why docker container exits immediately
In Docker, a container is automatically exited when the task is finished. You have to specify a correct entrypoint to keep your docker container up.
You can check the exited containers with the command docker ps -a. This exited container will prevent you from using the name again.
So, you may want to use docker rm <container-name> before creating your new container. In a test environement, you can also use docker system prune to clean all unused container/networks.
docker ps only shows the active containers (the running ones).
Your container most probably exited right after you started it. You can use the container ID and do docker logs <container-id> to examine the reason why the container failed.
If you want to see the stopped containers together with the running containers you can do docker ps -a to get a list of all these.
Execute
docker logs <CONTAINER ID>
to view the logs of docker container run.
I faced a similar issue found out there was space issue win my docker. After clearing space the container was able to run.
"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 installed from here a simple training application https://github.com/dockersamples/example-voting-app
After that i want to remove working containers and then images of this app. I`m trying type this:
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rm -f *containers*
First everything is deleted, but then the containers are restarted and recreated automatically even though I deleted this folder from the computer with the application.
And have this error
Error response from daemon: You cannot remove a running container
Probably autostart is registered in docker-compose-files, but I already deleted the folder with this project from my mac
Every time i have 3 this running containers :
dockersamples/visualizer:stable "npm start" vote_vis
dockersamples/examplevotingapp_result:before "node server.vote_res
postgres:9.4 "docker-entry vote_db.
How can i fix it and delete everything?
You probably have the containers running in swarm mode. When you stop or delete a container, swarm mode will see the difference from the target state and redeploy containers to get you to the target state. To stop and delete containers started by swarm mode, you need to run stack and service commands instead:
docker stack rm $(docker stack ls --format '{{.Name}}')
Give that a minute to complete, then for any services not managed as a stack, you can run:
docker service rm $(docker service ls -q)