Docker push failing — tag does not exist
Platform Notice: Cloud Only - This article only applies to Atlassian apps on the cloud platform.
Summary
As part of the planned Docker Client upgrade, docker cli is upgraded from v19.03.15 to v20.10.15.
Unfortunately, this upgrade introduced some breaking changes which have impacted a small number of users who are using Bitbucket Pipelines. Some pipelines may fail when pushing Docker images from pipelines, with errors similar to the below
docker push ${IMAGE_NAME}
Using default tag: latest
The push refers to repository [<repository>]
tag does not exist: <repository>:latestCause
In June 2022, Bitbucket Pipelines upgraded to Docker CLI version v20.10.15. Prior to Docker CLI version 20, the docker push command would push all available image tags if no tag was specified. For version 20, the Docker CLI updated the docker push command to try to push the latest tag, if a tag is not specified. If the latest tag does not exist, the command will fail. For more details please refer here.
Solution
To resolve the issue, update the docker push command in the pipeline to either:
Add the
--all-tags(or-a) option to thedocker pushcommand to push all available tags. Such as:docker push --all-tags IMAGE_NAMEor
docker push -a IMAGE_NAMESpecify the tag to be pushed, such as:
docker push IMAGE_NAME:TAGManually install the docker v19.03.15 client (see below).
Downgrading or using an alternative client
To downgrade or use an alternative Docker client, you can install it manually, and place it at the beginning of the $PATH variable.
For example to download v19.03.15:
pipelines:
default:
- step:
services:
- docker
script:
- curl -s -O https://download.docker.com/linux/static/stable/x86_64/docker-19.03.15.tgz
- tar --extract --file=docker-19.03.15.tgz
- ls -al ./docker
- export PATH=./docker:$PATH
- which docker
- docker versionWas this helpful?