I implemented my own docker registry and test it from localhost (push) and from my server (pull) successfully. Now, I am trying to build and push image from my CI pipeline:
build:
image: docker:18
services:
- docker:dind
stage: build
script:
- echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
- docker pull $CI_REGISTRY/website:latest
- docker build -t $CI_REGISTRY/website:latest .
- docker push $CI_REGISTRY/website:latest
I am able to log into registry:
$ echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
And when I am trying to pull my website:latest image, I am receive error:
$ docker pull $CI_REGISTRY/website:latest
Error response from daemon: pull access denied for registry.gitlab.com/website, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
I configured all variables properly in CI/CD -> Variables but I can see here registry.gitlab.com as my registry.I tried to rename CI_REGISTRY to CI_REGISTRY_ADDRESS, because I thought, maybe gitlab is using it as system variable and I cannot replace it (even when I am using this settings, variables and login, the same way like in another project, and its working). So now, I am receiving this error:
$ echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY_ADDRESS
Error response from daemon: Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password
I tried to google the solution, but didnt fine anything helpful. I am not sure why this settings works for another project and not for this one. Maybe I am missing something, not sure what. Could anybody help me to figure out what cause the problem and how to configure personal registry
EDIT1: Just example that the same configuration works fine on my another project:
$ echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
After this successful login, I am able to push and pull image.