I want to remove the container at Docker, but an error occurs when you want to delete
My next step before removing the container, see the list of existing container
sts@Yudi:~/docker$ sudo docker ps -as
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE
78479ffeba5c ubuntu "/bin/bash" 42 hours ago Exited (0) 42 hours ago sharp_wescoff 81 B (virtual 187.7 MB)
0bd2b54678c7 training/webapp "python app.py" 5 days ago Exited (0) 5 days ago backstabbing_ritchie 0 B (virtual 323.7 MB)
0adbc74a3803 training/webapp "python app.py" 5 days ago Exited (143) 5 days ago drunk_feynman 0 B (virtual 323.7 MB)
one I want to delete the list, namely "training / webapp" but an error that occurred
sts@Yudi:~/docker$ sudo docker rmi training/webapp
Error response from daemon: conflict: unable to remove repository reference "training/webapp" (must force) - container 0bd2b54678c7 is using its referenced image 54bb4e8718e8
Error: failed to remove images: [training/webapp]
Whether the container is running in the images?
Please help
you can use
-f
option to force delete the containers .sudo docker rmi -f training/webapp
You may stop the containers using
sudo docker stop training/webapp
before deletingFirst, remove the container names
The result
delete the second part, which is listed on the container to be deleted
Second, remove the container
The result
Check the continer
If you want to cleanup docker images and containers
CAUTION: this will flush everything
stop all containers
remove all containers
remove all images
Remove docker images >
List all containers
docker container ls
List all images
docker image ls
Stop container by container id
docker container stop
Remove container by container id
docker container rm
If don't want stop and remove, can force remove
docker container rm -f
Remove image
docker image rm
Done!
There is a difference between docker images and docker containers. Check this SO Question.
In short, a container is a running instance of an image. which is why you cannot delete an image if there is a running container from that image. You just need to delete the container first.
Update for Docker 1.13+ [Since Jan 2017]
Basically, above commands could also be rewritten, more clearly, as:
Also, if you want to remove EVERYTHING you could use:
If you have multiples docker containers launched, use this
$ docker rm $(docker ps -aq)
It will remove all the current dockers listed in the "ps -aq" command.
Source : aaam on https://github.com/docker/docker/issues/12487