Reputation: 4417
Okay, so I'm brand new to Docker and doing some tutorials and I want to delete the nginx
and mongo
images:
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest be1f31be9a87 12 days ago 109MB
mongo 3.4 598e8cf490a6 12 days ago 361MB
So I start with nginx
:
$ docker image rm nginx
Untagged: nginx:latest
Untagged: nginx@sha256:9ad0746d8f2ea6df3a17ba89eca40b48c47066dfab55a75e08e2b70fc80d929e
Deleted: sha256:be1f31be9a87cc4b8668e6f0fee4efd2b43e5d4f7734c75ac49432175aaa6ef9
Deleted: sha256:7609c40a03b852382a43d79231d9d4ca7661cd1ac9edcb46f78a44fff4ed59ca
Deleted: sha256:a2b6968c4326640dd5e9e22ddf6cebb61ba1a4b79a4ac8d194f93000c5a4c3e2
Deleted: sha256:8b15606a9e3e430cb7ba739fde2fbb3734a19f8a59a825ffa877f9be49059817
Has it gone?
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
mongo 3.4 598e8cf490a6 12 days ago 361MB
So far so good. Now for mongo
:
$ docker image rm mongo
Error: No such image: mongo
Why didn't this work?
In the end I found that docker image rm 598e8cf490a6
did remove the mongo
image, but I still don't understand why this didn't work.
REPOSITORY
? Is that the image name, or something else?mongo
image using docker image rm mongo
?docker image ls
show it instead of the image name?docker image rm mongodb
and docker image rm mongo-db
with no success.Upvotes: 7
Views: 10613
Reputation: 4184
The "name" of an image in docker is a combination of repository and ID - this is what is shown in docker image ls
.
You will find the repository name on the docker hub as well, e.g.: https://hub.docker.com/_/mongo/
If you provide only the name of the repository - in this case "mongo", docker assumes that you would like to delete the image which is tagged "latest" for this repository. Now since in your example you have only one image tagged "mongo:3.4", but no image called "mongo:latest", this doesn't work.
You can force to remove all images from one repository by adding the -f
flag, e.g. docker rmi -f mongo
.
See the official documentation for more information and examples: https://docs.docker.com/engine/reference/commandline/rmi/#parent-command
Upvotes: 0
Reputation: 1
If you are using a proxy, try
$ docker image rm your-proxy:port/image-name
or
$ docker image rm -f your-proxy:port/image-name
Upvotes: 0
Reputation: 316
As explained in the following thread - https://stackoverflow.com/a/23736802/10488199
An instance of an image is called a container. You have an image, which is a set of layers as you describe. If you start this image, you have a running container of this image. You can have many running containers of the same image. You can see all your images with docker images whereas you can see your running containers with docker ps (and you can see all containers with docker ps -a). So a running instance of an image is a container.
To view the list of running container instances
use -> $ docker ps
To view the list of all the container instances
use -> $ docker ps -a
To view, the list of images pulled
use -> $ docker images
To remove a container instance (if the container is running)
use -> $ docker kill <container id/container name>
use -> $ docker rm <container id/container name>
or force it to stop and remove it by
use -> $ docker rm -f <container id/container name>
To remove a container instance (if the container is not running)
use -> $ docker rm <container id/container name>
To remove an image
use -> $ docker rmi <REPOSITORY:tag/IMAGEID>
or
use -> $ docker image rm <REPOSITORY:tag/IMAGEID>
NOTE: If the REPOSITORY being removed has the latest tag, there is no need of mentioning it. If there is a tag, it should be mentioned.
In your case
use -> $ docker images rm mongo:3.4
Upvotes: 7