My bitbucket pipelines are failing with tag does not exist referring to dockerhub image push
this is the bitbucket-pipelines.yaml config
image: node:8
pipelines:
default:
- step:
name: Build Docker Image
caches:
- docker
script:
- echo 'Building Docker image but skipping Deploy for feature branch'
- sh ./build-docker.sh
branches:
development:
- step:
name: Deploy to Development
caches:
- docker
deployment: test
script:
- export DOCKER_BUILDKIT=0
- export LABEL=$(TZ=':America/Phoenix' date +%Y%m%d%H%M)
- sh ./deploy.sh development ${LABEL}
staging:
- step:
name: Deploy to Staging
caches:
- docker
deployment: staging
script:
- export DOCKER_BUILDKIT=0
- export LABEL=$(TZ=':America/Phoenix' date +%Y%m%d%H%M)
- sh ./deploy.sh staging ${LABEL}
qa:
- step:
name: Deploy to QA
caches:
- docker
deployment: production
script:
- export DOCKER_BUILDKIT=0
- export LABEL=$(TZ=':America/Phoenix' date +%Y%m%d%H%M)
- sh ./deploy.sh qa ${LABEL}
demo:
- step:
name: Deploy to Demo
caches:
- docker
deployment: test
script:
- export DOCKER_BUILDKIT=0
- export LABEL=$(TZ=':America/Phoenix' date +%Y%m%d%H%M)
- sh ./deploy.sh demo ${LABEL}
master:
- step:
name: Deploy to Production
caches:
- docker
deployment: production
script:
- export DOCKER_BUILDKIT=0
- export LABEL=$(TZ=':America/Phoenix' date +%Y%m%d%H%M)
- sh ./deploy.sh master ${LABEL}
options:
docker: true
build-docker.sh
#!/usr/bin/env bash
ENVIRONMENT=${1}
BITBUCKET_COMMIT=${BITBUCKET_COMMIT}
BITBUCKET_BRANCH="${BITBUCKET_BRANCH:-${ENVIRONMENT}}"
# Build Docker image
docker login -u ${DOCKER_USER} -p ${DOCKER_PASSWORD}
docker build -t intraedge/truyo-php:${ENVIRONMENT}-${BITBUCKET_COMMIT} -t intraedge/truyo-php:${ENVIRONMENT} --build-arg env=${ENVIRONMENT} .
if [[ $BITBUCKET_BRANCH == 'oci-poc' ]] || [[ $BITBUCKET_BRANCH == 'development' ]] || [[ $BITBUCKET_BRANCH == 'staging' ]] || [[ $BITBUCKET_BRANCH == 'qa' ]] || [[ $BITBUCKET_BRANCH == 'master' ]]; then
# and push to repository
docker push intraedge/truyo-php:${ENVIRONMENT}
docker push intraedge/truyo-php:${ENVIRONMENT}-${BITBUCKET_COMMIT}
fi;
and deploy.sh
#!/usr/bin/env bash
ENV=${1}
COMMIT=${BITBUCKET_COMMIT}-${2}
# Build Docker image and push to repository
docker login -u ${DOCKER_USER} -p ${DOCKER_PASSWORD}
docker build -t intraedge/truyo-php:${ENV}-${COMMIT} -t intraedge/truyo-php:${ENV} --build-arg env=${ENV} .
docker push intraedge/truyo-php:${ENV}
docker push intraedge/truyo-php:${ENV}-${COMMIT}
the docker version being used is
<span>+ docker version</span>
<span>Version: 20.10.24</span><span>API version: 1.39</span><span>Go version: go1.19.7</span><span>Git commit: 297e128</span><span>Built: Tue Apr 4 18:17:06 2023</span><span>OS/Arch: linux/amd64</span><span>Context: default</span><span>Experimental: true</span>
check the below article which mentions same issue as mine
https://confluence.atlassian.com/bbkb/docker-push-failing-tag-does-not-exist-1142430671.html
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.
It mentions
Downgrading or using an alternative client might help.
But this did not help us
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 version
any other solution would be appreciated