Resolves Jenkins problems that cannot be pushed to a private registry after creating Docker image

Source: Internet
Author: User

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= "}}} 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.