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

Docker inspect failing on FROM statements with ARG

      Docker 17.05 introduced the ability to use ARG values in FROM statements. See the release notes or pr.

       

      For example

      ARG BASE_IMAGE=centos:centos7
      FROM ${BASE_IMAGE}

       

      Using docker.build from the docker workflow plugin will fail with the following exception if the Dockerfile uses ARG values in its FROM statement...

       

      java.io.IOException: Cannot retrieve .Id from 'docker inspect${BASE_IMAGE}'
      	at org.jenkinsci.plugins.docker.workflow.client.DockerClient.inspectRequiredField(DockerClient.java:193)
      	at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:119)
      	at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:75)
      	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
      	at hudson.security.ACL.impersonate(ACL.java:260)
      	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)

          [JENKINS-44836] Docker inspect failing on FROM statements with ARG

          Nuno Costa added a comment -

          Still an issue on Jenkins 2.73 and docker-workflow 1.12.

          Nuno Costa added a comment - Still an issue on Jenkins 2.73 and docker-workflow 1.12.

          Nuno Costa added a comment -

          Still an issue with Jenkins 2.105 and docker-workflow 1.15.

          Based on Dockerfile with example above, docker image is downloaded, built and tagged but fails on inspect.

          Build command:

          docker.build("mycentos7", ".")
          

          Error:

          ...
          Status: Downloaded newer image for centos:centos7
           ---> ff426288ea90
          Successfully built ff426288ea90
          Successfully tagged mycentos7:latest
          [Pipeline] dockerFingerprintFrom
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          [Bitbucket] Notifying commit build result
          [Bitbucket] Build result notified
          java.io.IOException: Cannot retrieve .Id from 'docker inspect${BASE_IMAGE}'
          	at org.jenkinsci.plugins.docker.workflow.client.DockerClient.inspectRequiredField(DockerClient.java:222)
          	at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:133)
          	at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:85)
          	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
          	at hudson.security.ACL.impersonate(ACL.java:290)
          	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
          	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
          	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          	at java.lang.Thread.run(Thread.java:748)
          Finished: FAILURE
          

          Nuno Costa added a comment - Still an issue with Jenkins 2.105 and docker-workflow 1.15. Based on Dockerfile with example above, docker image is downloaded, built and tagged but fails on inspect. Build command: docker.build( "mycentos7" , "." ) Error: ... Status: Downloaded newer image for centos:centos7 ---> ff426288ea90 Successfully built ff426288ea90 Successfully tagged mycentos7:latest [Pipeline] dockerFingerprintFrom [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline [Bitbucket] Notifying commit build result [Bitbucket] Build result notified java.io.IOException: Cannot retrieve .Id from 'docker inspect${BASE_IMAGE}' at org.jenkinsci.plugins.docker.workflow.client.DockerClient.inspectRequiredField(DockerClient.java:222) at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:133) at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:85) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47) at hudson.security.ACL.impersonate(ACL.java:290) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang. Thread .run( Thread .java:748) Finished: FAILURE

          I just pass ARG to docker image and problem gone

          For example:

          • Dockerfile
            ARG BASE_IMAGE=centos:centos7
            FROM ${BASE_IMAGE}
            
          • Build command in Jenkins Pipeline
            docker.build("mycentos7", "--build-arg BASE_IMAGE=centos:centos7 .")
            

            or you can pass your variable like this:

            docker.build("mycentos7", "--build-arg BASE_IMAGE=${JENKINS_VAR_BASE_IMAGE} .")
            

          Alexey Burykin added a comment - I just pass ARG to docker image and problem gone For example: Dockerfile ARG BASE_IMAGE=centos:centos7 FROM ${BASE_IMAGE} Build command in Jenkins Pipeline docker.build( "mycentos7" , "--build-arg BASE_IMAGE=centos:centos7 ." ) or you can pass your variable like this: docker.build( "mycentos7" , "--build-arg BASE_IMAGE=${JENKINS_VAR_BASE_IMAGE} ." )

          I've discovered the same work around – that you must pass the FROM ARG. However, I vaguely recall that I couldn't get it work with an ARG constructing past of the FROM such as:

          ARG BASE
          FROM ${BASE}:my-tag
          

          but that issue may have already been resolved.

          Joshua Hoblitt added a comment - I've discovered the same work around – that you must pass the FROM ARG . However, I vaguely recall that I couldn't get it work with an ARG constructing past of the FROM such as: ARG BASE FROM ${BASE}:my-tag but that issue may have already been resolved.

          If you want to add default value to AGR look at official docs on docker.com -> ARG -> default values and scope
          https://docs.docker.com/engine/reference/builder/#default-values

          Alexey Burykin added a comment - If you want to add default value to AGR look at official docs on docker.com -> ARG -> default values and scope https://docs.docker.com/engine/reference/builder/#default-values

          Jeff Kwan added a comment -

          Similar issue:

          If the first line ends with a line continuation character instead of the image tag, it blows up too:

           

          FROM \
            mycentos:mytag
          

          You get:
          java.io.IOException: Cannot retrieve .Id from 'docker inspect \'

          Jeff Kwan added a comment - Similar issue: If the first line ends with a line continuation character instead of the image tag, it blows up too:   FROM \   mycentos:mytag You get: java.io.IOException: Cannot retrieve .Id from 'docker inspect \'

            christophlinder Christoph Linder
            philster_jenkins Phil Clay
            Votes:
            6 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated: