How to push docker images to another registry

Posted April 12, 2021 by Adrian Wyssmann ‐ 2 min read

Sometimes it may be necessary to 'copy' docker images from one registry to another one - which is a very easy thing to do

At my employer we don’t have direct internet access, so if one needs to download docker image, she/he needs to use the internal registry (JFrog Artifactory), rather the official docker registry. Artifactory itself runs on kubernetes as well, thus relying on docker images - images hosted by itself. This can cause troubles when you want to upgrade Artifactory and requires to download new docker images. This we have setup a fallback registry using docker-registry. In order to have the fallback images stored in this registry we have to “copy” them there.

All you have to do are these simple steps:

  1. Download the image you need

    [[email protected] ~]$ docker pull docker.prd.intra/bitnami/postgresql:9.6.18-debian-10-r7
    9.6.18-debian-10-r7: Pulling from bitnami/postgresql
    8639931041da: Pull complete
    4d3c20145e72: Pull complete
    31d2e2fd56b9: Pull complete
    2df5129bdc5b: Pull complete
    4d1738d978de: Pull complete
    64b240571161: Pull complete
    262647e176df: Pull complete
    df100498f366: Pull complete
    2c124d31d59a: Pull complete
    c491889bfe7f: Pull complete
    78eafaf7caa5: Pull complete
    Digest: sha256:a63224f91d0bd2dc9489337862ce37188a2e3378dfb4bef7133cbecea2a64cc0
    Status: Downloaded newer image for docker.prd.intra/bitnami/postgresql:9.6.18-debian-10-r7
    [[email protected] ~]$ docker images
    docker.prd.intra/bitnami/postgresql 9.6.18-debian-10-r7 eb0a50f73ced 10 months ago 338MB
  2. Tag the image, using the url from the fallback-registry (docker-fallback.prd.intra):

    [[email protected] ~]$ docker tag docker.prd.intra/bitnami/postgresql:9.6.18-debian-10-r7 docker-fallback.prd.intra/bitnami/postgresql/9.6.18-debian-10-r7
    [[email protected] ~]$ docker images
    docker-fallback.prd.intra/bitnami/postgresql/9.6.18-debian-10-r7 latest eb0a50f73ced 10 months ago 338MB
    docker.prd.intra/bitnami/postgresql 9.6.18-debian-10-r7 eb0a50f73ced 10 months ago 338MB
  3. Now that we have tagged the image, we can push it to the fallback-registry

    [[email protected] ~]$ docker login docker-fallback.prd.intra -u fallback
    Login Succeeded
    [[email protected] ~]$ docker push
    The push refers to repository [docker-fallback.prd.intra/bitnami/postgresql]
    4af4a3a6d7f5: Layer already exists
    49e1d446487d: Layer already exists
    3cf57cb27d57: Layer already exists
    e4d0e4ffe969: Layer already exists
    58eb215ff1bf: Layer already exists
    24a67c88dc5c: Layer already exists
    e2b9ee1ce16d: Layer already exists
    b2ff695f59b5: Layer already exists
    e47dc03a6e0c: Layer already exists
    b8d0de821c92: Layer already exists
    915e1ffcd29c: Layer already exists
    9.6.18-debian-10-r7: digest: sha256:a63224f91d0bd2dc9489337862ce37188a2e3378dfb4bef7133cbecea2a64cc0 size: 2623

That’s it, the image is now available on the fallback-registry.