Pull image from gitlab project container registry from a docker in docker container process in CI build

Hi,

Hi, I am using docker in docker executor as part of CI process. A build job in my gitlab CI starts a pytest process. One of the pytest session fixtures launches a
docker-compose process that attempts to pull a base image from the gitlab project’s container registry.

However, access is denied to the registry for the docker in docker process.

I have managed to grant access to the container registry for the CI build process, using the build yaml listed below. How can I grant access to the docker in docker process to pull an image from the git lab project’s container registry?

image: registry.gitlab.com/plantoeducate/devops:latest

stages:
  - build
  - test

variables:
  DOCKER_DRIVER: overlay2
  DOCKER_HOST: tcp://docker:2375
  SHARED_PATH: /builds/shared/$CI_PROJECT_PATH
  POSTGRES_DB: <...>
  POSTGRES_USER: <...>
  POSTGRES_PASSWORD: <....>
  DATABASE_URL: <...>

services:
  - name: registry.gitlab.com/plantoeducate/devops/dind-git/dind-git
    alias: docker
  - name: registry.gitlab.com/plantoeducate/api-db:latest
    alias: postgres

before_script:
    - 'which ssh-agent'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts

build:
  script:
    - mkdir -p ${SHARED_PATH}
    - echo "Building..."
    - pip install -r requirements.txt
    - echo "Cloning p2edu_fileserver.git into ${SHARED_PATH}..."
    - git clone git@gitlab.com:dcs3spp/p2edu_fileserver.git ${SHARED_PATH}
    - export FILE_SERVER_DIR=${SHARED_PATH}
    - echo "Running tests..."
    - pytest

Resolved the issue by logging in to the container registry in before_script…