Docker How To Remove Tag
To untag an image you basically remove that tagged version of the image. If you remove the last tagged version of an image, the entire image will be deleted.
Remove version tagged as “latest” by default:
docker rmi my_image
Remove version tagged as “v1”:
docker rmi my_image:v1
Untagging Docker Image While In Use
If the last tagged version of an image is still in use by a container, you need to force remove it:
docker rmi -f my_image:v1
After this you will notice the following:
- The image will remain but be untagged. Both the repo and the tag will be set to “
". - The container will still remain running.
- You should still be able to stop/start the container.
Another Observation
If an image only has one tag and you use that repo/tag combo to tag a different image with a different ID. The original image will now be without a repo/tag and will use values of “none”.
Notice how in this example I used “mysql:latest” to tag an ubuntu image. The mysql image was left without a name. You can still identify it based on the image ID.
(base) user1@zippy-zap:~/test23$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest 54150e9955c4 4 days ago 577MB
ubuntu a 5a81c4b8502e 5 weeks ago 77.8MB
ubuntu latest 5a81c4b8502e 5 weeks ago 77.8MB
(base) user1@zippy-zap:~/test23$ docker tag 5a81c4b8502e mysql
(base) user1@zippy-zap:~/test23$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 54150e9955c4 4 days ago 577MB
mysql latest 5a81c4b8502e 5 weeks ago 77.8MB
ubuntu a 5a81c4b8502e 5 weeks ago 77.8MB
ubuntu latest 5a81c4b8502e 5 weeks ago 77.8MB
(base) user1@zippy-zap:~/test23$
</code></pre>