Reputation: 802
I'm trying to tag auto-built Docker images on my private Registry within GitLab-CI, but the 'release' job fails with:
Error response from daemon: No such image: dev.skibapro.de:5050/dransfeld/dockerci-test:v0.4
This is my .gitlab-ci.yml
, the build and test jobs run without errors and docerci-test:v0.4 is present in my Registry after the pipeline has run.
image: docker:stable
variables:
DOCKER_DRIVER: overlay2
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
services:
- docker:dind
stages:
- build
- test
- release
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
build:
only:
- tags
stage: build
script:
- docker build -t $IMAGE_TAG -f docker/Dockerfile .
- docker push $IMAGE_TAG
test:
only:
- tags
stage: test
script:
- docker run $IMAGE_TAG /usr/local/bin/test.sh
release:
only:
- tags
stage: release
script:
- docker tag $IMAGE_TAG "$CI_REGISTRY_IMAGE:latest"
This is the error I'm getting in the job log:
$ docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Login Succeeded
$ docker tag $IMAGE_TAG "$CI_REGISTRY_IMAGE:latest"
Error response from daemon: No such image: dev.skibapro.de:5050/dransfeld/dockerci-test:v0.4
ERROR: Job failed: exit code 1
I don't know it the image just isn't present yet when the 'release' stage runs, or if I'm asking docker to do something it can't... I want the latest tag to only be applied after the test stage finished successfully.
Upvotes: 1
Views: 12159
Reputation: 802
Altough Docker seems to support tagging images in remote registries (Add remote tag to a docker image), GitLab needs to pull the image from the remote registry first. From GitLab's Blog (https://about.gitlab.com/2016/05/23/gitlab-container-registry/)
release-image:
stage: release
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
Upvotes: 6