Gitlab login error

I’m using gitlab to ssh to my server and pull the new registry to update my backend but sometime when it run into comand

docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY};

it giving some error like this :

Error response from daemon: Get "https://registry.gitlab.com/v2/": dial tcp: lookup registry.gitlab.com: Temporary failure in name resolution

Anyonce have the same issue. Thanks

This is a DNS problem and there is a high chance it is not related to gitlab itself.

Can you add more context please ?

Where do you execute the docker login command ?

docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY};

Do you run it from your gitlab-ci,yml file ? if yes, where are your runners hosted: are you using gitlab.com shared runners or are you self hosting your own runners ?


EDIT: Otherwise, it you are trying to login from your own server try an nslookup to see whether you can resolve registry.gitlab.com.

nslookup registry.gitlab.com
1 Like

Yes i run it from gitlab-ci.yml inside the script tag and i’m using gitlab share runners.
i’m also try nslookup to registry.gitlab.com and here’s the result :
image

Thank you for the clarifications.

Can you share the code for the job where you try to docker login ?

1 Like

yes here :

deploy:
  stage: deploy
  variables:
    GIT_STRATEGY: none
  only:
    - main
  before_script:
    - apk update && apk add openssh-client bash
  script:
    - >
      ssh $SSH_USER@$SSH_SERVER_IP
      "docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY};

EDIT: It not happen all the time, sometime i get this error but when i rerun it , it’s work. I don’t know what is the problem here ? Thanks

The failing resolution comes from the server, not from the gitlab runner. There may be a problem in the DNS resolution in your server. This can be anything, and it is a bit hard to know the reason.

Try using another nameserver or adding an additional one for the DNS resolution to fallback in case the default 127.0.0.1:53 fails.

On your server add this to /etc/resolv.conf.

# /etc/resolv.conf 
nameserver 8.8.8.8
1 Like

Side note: docker support running commands via ssh without using the ssh client directly.
Instead of:

ssh $SSH_USER@$SSH_SERVER_IP
      "docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY};

You can do either

docker -H ssh://$SSH_USER@$SSH_SERVER_IP login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY};

Or just create a DOCKER_HOST variable. It will automatically get picked by docker add used to run your commands.

variables:
  DOCKER_HOST: $SSH_USER@$SSH_SERVER_IP # You can define it globally on the UI if you don't use multiple hosts.
script: 
  - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY};

You can learn more about this here:

1 Like

Thank you so much i will try it

1 Like