1

I have a private docker repository where i store my build images. I did copy my registry certificates and updated my /etc/hosts file to authenticate registry from my local machine.

I could login to registry with 'sudo docker login -u xxx -p xxx registry-name:port'

But when i try same docker login command from gitlab-ci stage, it is failing with this error:

sudo: no tty present and no askpass program specified.

This is how i'm trying to achieve this.

ssh manohara@${DEPLOY_SERVER_IP} "sudo docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}"

I also tried adding this gitlab-runner ALL=(ALL) NOPASSWD: ALL at the bottom of /etc/sudoers file, but no luck Where am i going wrong?

CodeNotFound
  • 22,153
  • 10
  • 68
  • 69

1 Answers1

0

According to this Source you can use

ssh -t remotehost "sudo ./binary"

The -t allocates a pseudo-tty.

Or in your example:

ssh -t manohara@${DEPLOY_SERVER_IP} "sudo docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}"
anstue
  • 990
  • 12
  • 24