Recently began to use Docker, the common command to touch once, want to put the image of the build process on the Jenkins. The specific process will not say, very simple, only need a few commands on it.
An exception can be reported when pushing to a private registry:
Docker push registry.mydocker.com/demo/small:latest The
push refers to Repository [registry.mydocker.com/demo/ Small]
c4f96d93d165:preparing
94d1eb2ae195:preparing
c53e037f4c89:preparing
e15afa4858b6: Preparing
denied:requested access to the resource are denied build step
' Execute shell ' marked build as Failure
finished:failure
The reason: Before you push, you need to use the Docker login command to complete the login.
However, the Jenkins Job command is executed in the name of the pseudo user Jenkins, so it is not possible to complete the login directly in the Jenkins account. So how to solve it. Use the root account to complete the login to copy the. Docker directory under the/root/directory to the/var/lib/jenkins Modify folder permissions Chown-r Jenkins.jenkins. Docker
The principle is: The successful login will be in the. Docker to generate a Config.json file, which holds the authentication information, each time after the execution of Docker Pull/push, will be detected by the file to determine whether the user has completed certification. Config.json content:
{"auths": {"registry.mydocker.com": {"auth": " S2ptyw5nade53sm6mxeydznlnhapb2o= "}}}