Not looking for local images
Minimal .gitlab-ci.yml illustrating the issue
build backend-release:
image:
name: "gcr.io/kaniko-project/executor:v1.8.1-debug"
entrypoint: [""]
tags:
- "docker_build"
stage: build
variables:
BUILD_DOCKERFILE_DIR: "app/"
BUILD_IMAGE_NAME: "app-release"
BUILD_IMAGE_TAG: "$REGISTRY_URL/$REGISTRY_PROJECT/$BUILD_IMAGE_NAME:$CI_COMMIT_SHORT_SHA"
before_script:
- echo "{\"auths\":{\"${REGISTRY_URL}\":{\"username\":\"$DOCKER_REGISTRY_USER\", \"password\":\"$DOCKER_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
script:
- /kaniko/executor --no-push --context $BUILD_DOCKERFILE_DIR --destination $BUILD_IMAGE_TAG --build-arg GIT_COMMIT=$CI_COMMIT_SHORT_SHA --dockerfile $BUILD_DOCKERFILE_DIR/Dockerfile --cache=false --target production --skip-unused-stages
Expected behavior My Dockerfile includes the following line:
COPY --from=registry.docker.mycompany.com/app/mybinary:v1 /tmp/dist/ /tmp/dist/
I don't have pull access to registry.docker.mycompany.com however, i have the image locally in my pc. I would expect instead of trying to fetch remotely first, to search locally for an image with a matching tag
Host information MacOS M1 gitlab-ci-local 4.46.1
Containerd binary docker
Does gitlab.com search on their shared runners for the image locally instead of pulling it from remote?
@milouk,
This example might be relevant for your usecase.
Another approach is to setup a local registry
docker run -d -p 127.0.0.1:5000:5000 registry:2
and in .gitlab-ci-local-variables.yml
---
CI_REGISTRY: "127.0.0.1:5000"
then
gitlab-ci-local ...
@milouk Feel free to leave a clarification or edit your description. Just ping me if you want the issue reopened.