[JIRA] (JENKINS-41051) withRegistry is not doing a "docker login"

3 views
Skip to first unread message

davidmichaelkarr@gmail.com (JIRA)

unread,
Jan 12, 2017, 5:40:02 PM1/12/17
to jenkinsc...@googlegroups.com
David Karr created an issue
 
Jenkins / Bug JENKINS-41051
withRegistry is not doing a "docker login"
Issue Type: Bug Bug
Assignee: magnayn
Components: docker-plugin
Created: 2017/Jan/12 10:39 PM
Environment: Linux
Priority: Major Major
Reporter: David Karr

I have a block in my pipeline script like the following:

		docker.withRegistry("http://ourhost:5100", params.JP_DockerMechIdCredential) {
			def	image = docker.build("com.att.sharedservices/tomee-uslmonitor")
			image.push 'latest'
		}

Before this block of code, I extracted the username and password from the credential, and they are correct.

In the log, I watched it build the image, tag it, but then when it tried to push it, it failed to authenticate. I didn't see a "docker login" command line in the log.

I then tried to manually run the docker commands from the shell, on the same box the job is running on, starting with "docker login". That entire process worked.

I then reran my job, and it also worked.

I then moved my "~/.docker/config.json" file out of the way and reran my job, and it failed to authenticate again. It's just not attempting "docker login".

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

davidmichaelkarr@gmail.com (JIRA)

unread,
Jan 12, 2017, 6:20:01 PM1/12/17
to jenkinsc...@googlegroups.com
David Karr commented on Bug JENKINS-41051
 
Re: withRegistry is not doing a "docker login"

Note that I was able to implement a workaround, with a modified block like this:

		withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: params.JP_DockerMechIdCredential, usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
			usr = USERNAME
			pswd = PASSWORD
		}
		docker.withRegistry("http://ourhost:5100", params.JP_DockerMechIdCredential) {
			sh "docker login -u ${usr} -p ${pswd} http://ourhost:5100"
			def	image = docker.build("com.att.sharedservices/tomee-uslmonitor")
			image.push 'latest'
		}

vireshdoshi@gmail.com (JIRA)

unread,
Feb 18, 2018, 6:42:02 AM2/18/18
to jenkinsc...@googlegroups.com

I can also confirm that this worked!

I ended up using the following workaround:

// code placeholder
stage('Push image') {
/* Finally, we'll push the image with two tags:
* First, the incremental build number from Jenkins
* Second, the 'latest' tag. */
withCredentials([usernamePassword( credentialsId: 'docker-hub-credentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {

docker.withRegistry('', 'docker-hub-credentials') {
sh "docker login -u ${USERNAME} -p ${PASSWORD}"
myImage.push("${env.BUILD_NUMBER}")
myImage.push("latest")
}
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

michael.ermer@contactimpact.de (JIRA)

unread,
Feb 19, 2018, 10:46:02 AM2/19/18
to jenkinsc...@googlegroups.com

Docker 1.17+ no longer supports ~/.dockercfg so jenkins needs to create ~/.docker/config.json from now on.

https://github.com/moby/moby/commit/18c9b6c6455f116ae59cde8544413b3d7d294a5e

michael.ermer@contactimpact.de (JIRA)

unread,
Feb 19, 2018, 6:07:02 PM2/19/18
to jenkinsc...@googlegroups.com
Michael Ermer updated an issue
 
Change By: Michael Ermer
Comment:
Docker 1.17+ no longer supports ~/.dockercfg so jenkins needs to create ~/.docker/config.json from now on.

https://github.com/moby/moby/commit/18c9b6c6455f116ae59cde8544413b3d7d294a5e

jglick@cloudbees.com (JIRA)

unread,
May 17, 2018, 3:40:05 PM5/17/18
to jenkinsc...@googlegroups.com
Jesse Glick resolved as Duplicate
 

Already done.

Change By: Jesse Glick
Status: Open Resolved
Resolution: Duplicate

thongpm@gmail.com (JIRA)

unread,
Jul 26, 2019, 12:46:03 PM7/26/19
to jenkinsc...@googlegroups.com
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)
Reply all
Reply to author
Forward
0 new messages