I am trying to create my own containers using ci / cd in Gitlab and upload them in Gitlab. But the project's latest tag is expected to be replaced, but it will not be replaced in the next uploads. Do I need to add something to the code?
stage: build
image: 'docker:24.0.7-git'
services:
- docker:24.0.7-dind
script:
- apk update && apk add jq
- export VERSION=`jq -r ".version" < ./package.json`
- export CONTAINER_RELEASE_NAME="${CI_REGISTRY_IMAGE}/secure:${VERSION}"
- export CONTAINER_RELEASE_LATEST="${CI_REGISTRY_IMAGE}/secure:latest"
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker build -f Dockerfile.secure -t $CONTAINER_RELEASE_NAME -t $CONTAINER_RELEASE_LATEST --build-arg="NPM_TOKEN=$CI_JOB_TOKEN" .
- docker push $CONTAINER_RELEASE_NAME
- docker push $CONTAINER_RELEASE_LATEST
- docker logout
As shown in the photo, the latest tag has not been replaced.

The UI is a bit confusing but the tag it's being overwritten as you'd expect. Wording on the published column is not very accurate, as it only shows when the tag appeared on the registry for the first time.
To actually see if the image has been correctly updated, you can do the following:
my-image-tag: digest: sha256: XXXXXXXXXXXXXXXXXXX size: 1234Once you're there you have to compare that the latest digest is the same both in your pipeline output and in the details shown at the UI.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With