Skip to content

Docker push to different repo leads to denied: requested access to the resource is denied

I'm using GitLab 9.2.0 and want to docker pull, docker tag and then docker push a bunch of images in the same project group with the CI job at the bottom.

During the push of the 2nd image I get the error message denied: requested access to the resource is denied The user triggering the job is owner of the whole project-group

This is the job:

tag_all_production_images:
  stage: build
  image: docker:git
  services:
    - docker:dind
  script:
    - echo "Tagging images for deployment"
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    - echo "Tagging backend for production"
    - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
    - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME $CI_REGISTRY_IMAGE:production
    - docker push $CI_REGISTRY_IMAGE:production
    - echo "Tagging client for production"
    - docker pull $CI_REGISTRY/my-project/client:master
    - docker tag $CI_REGISTRY/my-project/client:master $CI_REGISTRY/my-project/client:production
    - docker push $CI_REGISTRY/my-project/client:production

This is the log:

Status: Downloaded newer image for registry.mycompany.com/my-project/client:master
$ docker tag $CI_REGISTRY/my-project/client:master $CI_REGISTRY/my-project/client:production
$ docker push $CI_REGISTRY/my-project/client:production
The push refers to a repository [registry.mycompany.com/my-project/client]
026d5e1b4a67: Preparing
26bfd3da347a: Preparing
a14edfdadcb7: Preparing
47cfe37bc901: Preparing
f6e23a4f8ce9: Preparing
152c6ccb5ab0: Preparing
a6a86e409c22: Preparing
f984f4465482: Preparing
f8791c056b24: Preparing
2e08149e674a: Preparing
f55f65539fab: Preparing
30339f20ced0: Preparing
0eb22bfb707d: Preparing
a2ae92ffcd29: Preparing
f984f4465482: Waiting
f8791c056b24: Waiting
2e08149e674a: Waiting
f55f65539fab: Waiting
30339f20ced0: Waiting
0eb22bfb707d: Waiting
a2ae92ffcd29: Waiting
152c6ccb5ab0: Waiting
47cfe37bc901: Layer already exists
26bfd3da347a: Layer already exists
a14edfdadcb7: Layer already exists
026d5e1b4a67: Layer already exists
f6e23a4f8ce9: Layer already exists
152c6ccb5ab0: Layer already exists
f984f4465482: Layer already exists
f8791c056b24: Layer already exists
a6a86e409c22: Layer already exists
2e08149e674a: Layer already exists
f55f65539fab: Layer already exists
0eb22bfb707d: Layer already exists
30339f20ced0: Layer already exists
a2ae92ffcd29: Layer already exists
errors:
denied: requested access to the resource is denied
unauthorized: authentication required

ERROR: Job failed: exit code 1
Edited by 🤖 GitLab Bot 🤖