How to tag Docker image in post deploy step?

We have a scenario where we build and push a docker image early in the deploy pipeline. We tag it with the git SHA.

After deploy, we want to tag this image with latest. I have two steps in the post deploy build that look like:

- run: |
          docker tag \
            HOST/elixir-umbrella-cypress-runner:$CIRCLE_SHA1 \
- run: docker push HOST/elixir-umbrella-cypress-runner:latest

This works sometimes. But sometimes I get this error:

I guess it’s because the image is not on the host in this case? I tried using docker pull to get it but that just hangs forever. Please advise.


(When you get an error and wish to show an image, would you also supply a text version (or supply a text version instead)? It is really helpful to other folks if text is supplied as text; this is compatible with clipboards, screen-readers, and search engines.)

What you could do to debug this is to do docker images after the build, so that if you get the “no such image” error again, you can at least compare that with what Docker does believe it has.

I’d figure out why docker pull is hanging because I believe you’d need that to work.

As you suggested, I believe the problem is that the image tag isn’t always available on the machine running the job. A combination of using Docker Layer Cache, a premium CircleCI feature, and docker pull will ensure that the image is available locally so that the regular tagging will work.

As Halfer mentioned, using docker images to output the list, perhaps with grep, should confirm this.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.