20

Imagine, I have docker image based on Dockerfile, I will tag & push it into docker registry

Over time, I change Dockerfile (add/change new instructions, ...)

Now, I will tag new image again with the same tag I used in the first place and push it into docker registry

  1. How does docker registry react to new layers?
  2. How does docker registry react to changed layers?
  3. Will it overwrite existing image with the latest version?
  4. Should I use different tag to make sure I have correct new image in place?
Patrik Mihalčin
  • 3,341
  • 7
  • 33
  • 68

1 Answers1

10

How does docker registry react to new layers? How does docker registry react to changed layers?

It will function the same as a pull -- unchanged layers will not be pushed again and new layers will be pushed.

Will it overwrite existing image with the latest version?

Yep.

Should I use different tag to make sure I have correct new image in place?

Usually. Using latest to represent the most recent is fine but you should add a second tag for the actual version so that dependent systems can pin to that version and upgrade as needed.

CashIsClay
  • 2,182
  • 18
  • 18
  • 14
    It doesn't seem to overwrite when I try. I'm editing `Dockerfile` then running `docker push username/repo:tag`. What am I missing? – sudo Oct 02 '17 at 19:09
  • 1
    https://docs.docker.com/ee/dtr/user/manage-images/prevent-tags-from-being-overwritten/#make-tags-immutable – Lewis Chan Sep 29 '18 at 11:38
  • 1
    Make sure you're running `docker build -t ...` before pushing. – Ryan Wheale Jun 29 '21 at 22:15
  • What happens to old layers that the tag no longer point to? Are they removed to save space in registry? – stoper Nov 17 '21 at 17:30