Trying to set up gitlab pipeline with docker-in-docker. I've created docker image from Dockerfile. It exists locally. When I run it manually from cli docker run -it docker-c sh
, it is runs correctly.
When it is done by the pipeline it seems to ignore that there's existing docker-c
image, and looks for it in the dockerhub
job output:
Running with gitlab-runner 17.3.1 (66269445)
on runner3 71qiPF29, system ID: s_2acc9531e625
Preparing the "docker" executor
00:07
Using Docker executor with image mcr.microsoft.com/powershell ...
Starting service docker-c:latest...
Pulling docker image docker-c:latest ...
WARNING: Failed to pull image with policy "always": Error response from daemon: pull access denied for docker-c, repository does not exist or may require 'docker login': denied: requested access to the resource is denied (manager.go:251:3s)
ERROR: Job failed: failed to pull image "docker-c:latest" with specified policies [always]: Error response from daemon: pull access denied for docker-c, repository does not exist or may require 'docker login': denied: requested access to the resource is denied (manager.go:251:3s)
/etc/gitlab-runner/config.toml
[runners.docker]
image = "docker-c"
.gitlab-ci.yaml
default:
tags:
- docker-dind
stages:
- docker-build
services:
- docker-c
get-env-vars:
stage: docker-build
image: mcr.microsoft.com/powershell
script: pwsh -Command "Get-ChildItem -Path env:"
image-build:
stage: docker-build
script:
- docker login --username $CI_REGISTRY_USER --password=$CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t mydockerimage .
needs:
- get-env-vars
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker-c latest 34ff2e633a4d 2 hours ago 362MB
you haven't creted docker image regitsry in your gitlab, gitlab pipeline won't be able to pull docker image from your local machine. you need to push it to the conatiner registry and pull it from there to be used in pipelines.you need to first:
we can clearly see in the error saying that ther repository does not exsist meaning you havent created registry to host your docker image.
WARNING: Failed to pull image with policy "always": Error response from daemon: pull access denied for docker-c, repository does not exist or may require 'docker login': denied: requested access to the resource is denied (manager.go:251:3s) ERROR: Job failed: failed to pull image "docker-c:latest" with specified policies [always]: Error response from daemon: pull access denied for docker-c, repository does not exist or may require 'docker login': denied: requested access to the resource is denied (manager.go:251:3s)
here is an article which you can refer and figure out what you are doing wrong: https://gitlab-docs.creationline.com/ee/user/packages/container_registry/build_and_push_images.html