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)
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.
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
I have some docker containers provisioned by docker-compose with restart: always flag. But I accidentally delete docker-compose.yml file.
How do I delete those containers so that they will not restart automatically?
Without the compose file, docker-compose can't guess the name of the containers that need to be killed. You need to do that manually using docker command:
docker container ls
docker rm -f <container-name-or-id>
You can use docker ps -a to list all the running containers. After you can use docker stop container-name to stop individually the containers you want and after you can use docker rm $(docker ps -a -q) to delete and remove all the stopped containers.
Also if you want to delete the docker images as well you can use docker images to list the existing images and after docker rmi image-name to delete the image.
I had a similar issue - I didn't want to fetch the .yml files just to remove the containers. As docker-compose adds labels to the containers, we can use these to filter the matching containers and then remove them.
To remove all the containers that docker-compose created for project ProjectName (normally the name of the folder where the docker-compose.yml was) in shell (bash or similar), execute the following:
docker ps --filter 'label=com.docker.compose.project=ProjectName' --format {{.ID}} | xarg -n 1 docker rm --force --volumes
docker ps with the filter provides the list of containers, the format is provided so that only container IDs are printed
xargs -n 1 - takes the list of container IDs and executes the target command on each of them providing the container ID as the argument to the target
docker rm removes existing containers
--force - to also stop running containers (otherwise running containers would not be stopped or removed)
--volumes - to also remove any anonymous volumes associated with the containers
I currently have a lot of docker containers running that are no longer used.
So many actually that it would take a while to exit and quit them all manually.
I was wondering if there was a way to exit and delete all of them except for the latest one ?
A quick approach to do this is the following:
First, stop all containers with this command:
docker stop $(docker ps -aq)
Then, start the container that you want to keep using:
docker start container_name
And finally, use docker container prune, which removes all stopped containers.
docker container prune