Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove a Local Docker Image Tag Without Deleting the Image

Tags:

docker

I'm new on the containers world and I recently have started with Docker. But I'm having some issues, and I couldn't find a solution ( at least one I understand minimally). So, here's the problem:

  • I want to delete a local image tag ("repository"/"tag" combination). Is it possible?
  • How can I, having multiple TAGs associated with just one image ID, delete any of these TAGs without deleting the others? In my case, I just wanna to exclude the hiworld repository. I'm able to delete the image and therefore all the TAGs associated with, but this is not what I want to do. Below is what is displayed when I enter the command docker images.
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
helloworld1         latest              8916c2510f76        3 hours ago         148MB
hiworld             latest              8916c2510f76        3 hours ago         148MB

Thanks in advance.

like image 940
Leonardo Maffei Avatar asked Jan 31 '18 21:01

Leonardo Maffei


1 Answers

docker rmi (the remove image command) does this.

$ docker rmi hiworld:latest

That will untag hiworld:latest, but will leave helloworld1:latest (and 8916c2510f76) in place. According to the docs,

If an image has one or more tags referencing it, you must remove all of them before the image is removed.

like image 94
mkasberg Avatar answered Oct 23 '22 16:10

mkasberg