Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gitlab docker container not overwrite latest tag

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 latest tag has not been replaced

like image 592
Reza Razani Avatar asked Apr 07 '26 08:04

Reza Razani


1 Answers

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:

  • Go to your pipeline and look for your tag digest, output will be similar to this when pushing: my-image-tag: digest: sha256: XXXXXXXXXXXXXXXXXXX size: 1234
  • At the Container Registry UI, click on the three dots next to your image name to toggle the details

Once 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.

like image 130
bhito Avatar answered Apr 09 '26 00:04

bhito