Private Docker Registry Harbor(2)Jenkins with Harbor

阅读更多
Private Docker Registry Harbor(2)Jenkins with Harbor


Add the self private registry
> sudo vi /etc/docker/daemon.json
{
    "insecure-registries": [“52.13.xx.xxx:49002"]
}
Try to docker login there
Error saving credentials: error storing credentials - err: exit status 1, out: `Cannot autolaunch D-Bus without X11 $DISPLAY`
Solution:
sudo apt install dbus-x11
> sudo apt install gnupg2 pass
Generate the key
> gpg2 --full-generate-key
> pass init "[email protected]"
Docker login Success
> docker login 52.13.xx.xxx:49002
Docker push success
> docker push 52.13.38.xxx:49002/connector/sillycat/netsuiteconnector:1.0
We ca login without prompt
> docker login 52.13.38.xxx:49002 -u="yiyikang" -p=“xxxxxxxx"

Here is how it release to Docker Registry
    stage('Release to Docker Registry') {
      steps {
        withCredentials([usernamePassword(credentialsId: 'yiyi_harbor', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
        sh '''
        docker build -f deployment/docker/Dockerfile -t 52.13.38.xxx:49002/connector/sillycat/netsuiteconnector:1.1 .
        docker login 52.13.38.xxx:49002 -u="$USERNAME" -p="$PASSWORD"
        docker push 52.13.38.xxx:49002/connector/sillycat/netsuiteconnector:1.1
    '''
        }
      }
    }

References:
https://stackoverflow.com/questions/51222996/docker-login-fails-on-a-server-with-no-x11-installed
https://stackoverflow.com/questions/43026637/how-to-get-username-password-stored-in-jenkins-credentials-separately-in-jenkins

你可能感兴趣的:(Private Docker Registry Harbor(2)Jenkins with Harbor)