web analytics

Docker re-tag images

Often there are tags with images when they are pulled. If you want to rename that tag, all you need to do is the following steps.

  1. Pull the image
  2. Re-tag the image using docker tag imagename:current_tag imagename:new_tag
  3. docker rmi image:current_tag

When you re-tag, it will leave you with two different images with different tags and we need to get rid of the old one using step3.

An example given below

  1. Pull the image
    [abc@host ~]$ sudo docker pull busybox:old
    musl: Pulling from library/busybox
    2bafa357a9a5: Pull complete
    Digest: sha256:658f4fcf74879ed5a01bf310d018099413f3b2588c1565ac54c85253ba3fc6d4
    Status: Downloaded newer image for busybox:old
    docker.io/library/busybox:old
  2. Verify the image
    [abc@host ~]$ sudo docker images
    REPOSITORY TAG    IMAGE ID     CREATED    SIZE
    busybox            old   21f6c69ffad2  2 weeks ago  1.47MB
  3. Re-tag the image
    [abc@host ~]$ sudo docker tag busybox:old busybox:new
  4. Verify the images
    [abc@host ~]$ sudo docker images
    REPOSITORY     TAG        IMAGE ID        CREATED       SIZE
    busybox                 old       21f6c69ffad2     2 weeks ago     1.47MB
    busybox                 new       21f6c69ffad2     2 weeks ago     1.47MB
  5. Untag the old image by removing it
    [abc@host ~]$ sudo docker rmi busybox:old
    Untagged: busybox:old
  6. Confirm only one image with latest tag alone is present
    [abc@host ~]$ sudo docker images
    REPOSITORY         TAG            IMAGE ID      CREATED           SIZE
    busybox                    new            21f6c69ffad2   2 weeks ago         1.47MB

 

 

 

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>