Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-58875

withRegistry's DOCKER_REGISTRY_URL isn't used by newer Docker versions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • docker-workflow-plugin
    • None

      Using a Scripted Pipeline with a private registry:

      node {
          docker.withRegistry('https://dockerregistry.tld', 'dockerregistry-credentials') {
              sh "env"
              sh "docker info"
              docker.build("private-project")
          }
      } 

      with this Dockerfile:

      Dockerfile
      FROM private-containers/private-container
      RUN echo "testing" > test

      which gives the following trimmed build output:

      Started by user anonymous
      [Pipeline] node
      Running on master in /Users/simlu/src/docker-workflow-plugin/work/workspace/meow
      [Pipeline] {
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] withDockerRegistry
      $ docker login -u username -p ******** https://dockerregistry.tld
      WARNING! Using --password via the CLI is insecure. Use --password-stdin.
      Login Succeeded
      [Pipeline] {
      [Pipeline] sh
      [meow] Running shell script
      + env
      […]
      DOCKER_REGISTRY_URL=https://dockerregistry.tld
      DOCKER_CONFIG=/Users/simlu/src/docker-workflow-plugin/work/workspace/meow@tmp/9db41f29-06a0-4f3e-bee1-eed0cea6d642
      […]
      MAVEN_CMD_LINE_ARGS= hpi:run
      […]
      [Pipeline] sh
      [meow] Running shell script
      + docker info
      Client:
       Debug Mode: false
      
      Server:
       Containers: 19
        Running: 0
        Paused: 0
        Stopped: 19
       Images: 148
       Server Version: 19.03.1
       Storage Driver: overlay2
        Backing Filesystem: extfs
        Supports d_type: true
        Native Overlay Diff: true
       Logging Driver: json-file
       Cgroup Driver: cgroupfs
       Plugins:
        Volume: local
        Network: bridge host ipvlan macvlan null overlay
        Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
       Swarm: inactive
       Runtimes: runc
       Default Runtime: runc
       Init Binary: docker-init
       containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
       runc version: 425e105d5a03fabd737a126ad93d62a9eeede87f
       init version: fec3683
       Security Options:
        seccomp
         Profile: default
       Kernel Version: 4.9.184-linuxkit
       Operating System: Docker Desktop
       OSType: linux
       Architecture: x86_64
       CPUs: 2
       Total Memory: 1.952GiB
       Name: docker-desktop
       ID: something
       Docker Root Dir: /var/lib/docker
       Debug Mode: true
        File Descriptors: 29
        Goroutines: 44
        System Time: 2019-08-09T12:50:56.902213375Z
        EventsListeners: 2
       HTTP Proxy: gateway.docker.internal:3128
       HTTPS Proxy: gateway.docker.internal:3129
       Registry: https://index.docker.io/v1/
       Labels:
       Experimental: false
       Insecure Registries:
        127.0.0.0/8
       Live Restore Enabled: false
       Product License: Community Engine
      
      [Pipeline] sh
      [meow] Running shell script
      + docker build -t private-project .
      Sending build context to Docker daemon   7.68kB
      
      Step 1/4 : FROM private-containers/private-container
      pull access denied for private-containers/private-container, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
      [Pipeline] }
      [Pipeline] // withDockerRegistry
      [Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      ERROR: script returned exit code 1
      Finished: FAILURE
      

      doesn't use the private registry, it tries to talk to Docker Hub.

      NOTE: that there is no Username: username output before the Registry: in docker info.

      This works with an older Docker-CE version, e.g. 18.09.7.

      Please let me know if there's anything else I can provide for this to be solved quicker.

            Unassigned Unassigned
            simmel Simon Lundstrom
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: