I have two repositories, let's call them project1 and project2. I can successfully build an image as project1_image from project1 and push it to the project1 container registry using a pipeline job in project1. However, when I try to build an image as project2_image and push it to the project2 container registry from project1's pipeline, I get the following error:
"denied: requested access to the resource is denied" when attempting to push.
Is it possible to create an image during project1's pipeline, name it project2_image, and push it to project2's container registry?
I am using gitlabs default runners.
Here is the .gitlab-ci.yml file in project1 that is attempting to push the image to project2.
build image:
stage: build
image: docker:stable
services:
- name: docker:dind
alias: thedockerhost
variables:
# Tell docker CLI how to talk to Docker daemon; see
# https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-in-docker-executor
DOCKER_HOST: tcp://thedockerhost:2375/
# Use the overlayfs driver for improved performance:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- docker build -t gitlab.com:5050/groupname/project2/pythonapp .
- docker push gitlab.com:5050/groupname/project2/pythonapp
Is it possible to create an image during project1's pipeline, name it project2_image, and push it to project2's container registry?
Yes.
"denied: requested access to the resource is denied" when attempting to push.
So use proper credentials. Auto supplied -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
are for accessing project1, not project2.