-2

Does tagging a Docker image create a copy of the image?

It seems to me tagging by itself shouldn't. But the following command seems to imply so.

Thanks.

$ docker image ls
REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
friendlyhello            latest              d9e555c53008        3 minutes ago       195MB
python                   2.7-slim            1c7128a655f6        5 days ago          183MB

$ docker tag friendlyhello gordon/get-started:part2

$ docker image ls
REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
friendlyhello            latest              d9e555c53008        3 minutes ago       195MB
gordon/get-started         part2               d9e555c53008        3 minutes ago       195MB
python                   2.7-slim            1c7128a655f6        5 days ago          183MB
2

No, a copy is not made.

You can tell this because the Image ID value is identical:

friendlyhello            latest              d9e555c53008        3 minutes ago       195MB
gordon/get-started       part2               d9e555c53008        3 minutes ago       195MB

This means they reference the same data. If you then do a docker rmi friendlyhello then it won't delete anything, just remove the tag.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.