A GitLab job needs to push a Docker image without Docker-in-Docker privileges.

IntermediateScenarioGitLab CI
Answer

Situation read → DinD needs privileged runners.

What I'd do →

  1. Use Kaniko or BuildKit rootless in the job image:
build_image:
  image: { name: gcr.io/kaniko-project/executor:debug, entrypoint: [""] }
  script:
    - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile Dockerfile
      --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
  1. Authenticate using $CI_REGISTRY_USER and $CI_REGISTRY_PASSWORD written to /kaniko/.docker/config.json.

Why → No privileged container and no Docker socket on the runner.

Interview tip → Compare with docker:dind plus DOCKER_TLS_CERTDIR.

All CI/CD questions Roadmap: GitLab CI/CD

More on GitLab CI