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

Docker build from Dockerfile requires full path to Dockerfile

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Set "path to docker context" field to "." and set "Dockerfile" field to "Dockerfile" and try a build, and get:

      {{Build Docker image from ./Dockerfile ...
      $ docker build --tag 6ae96f119c2701896c3890ff49f07078bcdcac37 --file Dockerfile /home/jenkins/workspace/cloud-acceptance
      unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/jenkins/Dockerfile: no such file or directory
      [ssh-agent] Stopped.
      FATAL: Failed to build docker image from project Dockerfile
      java.lang.RuntimeException: Failed to build docker image from project Dockerfile
      at com.cloudbees.jenkins.plugins.docker_build_env.Docker.buildImage(Docker.java:127)
      at com.cloudbees.jenkins.plugins.docker_build_env.DockerfileImageSelector.prepareDockerImage(DockerfileImageSelector.java:41)
      at com.cloudbees.jenkins.plugins.docker_build_env.DockerBuildWrapper.setUp(DockerBuildWrapper.java:167)
      at hudson.model.Build$BuildExecution.doRun(Build.java:156)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
      at hudson.model.Run.execute(Run.java:1738)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:98)
      at hudson.model.Executor.run(Executor.java:410)
      }}

      If I set "Dockerfile" field to "/home/jenkins/workspace/cloud-acceptance/Dockerfile" it builds without a problem.

      Either the build command needs to be run in the project workspace directory or the full path to the Dockerfile should be passed to the build command.

      Alternatively, docs should just clarify that the full path is needed and default to something useful (is there a variable that can be used in this field that contains the project workspace directory?)

        Attachments

          Activity

          Hide
          tcollignon Thomas Collignon added a comment - - edited

          Hi,

          We set Dockerfile field to :

          ${WORKSPACE}/Dockerfile
          

          and it's works.

          Can you try it?

          Show
          tcollignon Thomas Collignon added a comment - - edited Hi, We set Dockerfile field to : ${WORKSPACE}/Dockerfile and it's works. Can you try it?
          Hide
          johnl John Leach added a comment -

          yep, that works for me. Thanks. So should that be the default then?

          Show
          johnl John Leach added a comment - yep, that works for me. Thanks. So should that be the default then?
          Hide
          tcollignon Thomas Collignon added a comment -

          Oh I don't know that, maybe Nicolas has an other view?

          Maybe this could be added in the comment on the field

          Show
          tcollignon Thomas Collignon added a comment - Oh I don't know that, maybe Nicolas has an other view? Maybe this could be added in the comment on the field
          Hide
          tcollignon Thomas Collignon added a comment -

          Now with the new release 1.6.5 you don't have to set ${WORKSPACE}, just Dockerfile like you do at the beginning is good.

          Show
          tcollignon Thomas Collignon added a comment - Now with the new release 1.6.5 you don't have to set ${WORKSPACE}, just Dockerfile like you do at the beginning is good.
          Hide
          johnl John Leach added a comment -

          Ah, this looks much better with 1.6.5. I now no longer have to set ${WORKSPACE}/Dockerfile - I can set just Dockerfile. Thanks!

          But it's worth noting that I now CANNOT set ${WORKSPACE}/Dockerfile. If I do that, it errors like this:

          {{Your project is missing a Dockerfile
          [ssh-agent] Stopped.
          FATAL: Interrupted
          java.lang.RuntimeException: Interrupted
          at com.cloudbees.jenkins.plugins.docker_build_env.DockerBuildWrapper.setUp(DockerBuildWrapper.java:171)
          at hudson.model.Build$BuildExecution.doRun(Build.java:156)
          at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
          at hudson.model.Run.execute(Run.java:1738)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
          at hudson.model.ResourceController.execute(ResourceController.java:98)
          at hudson.model.Executor.run(Executor.java:410)}}

          Show
          johnl John Leach added a comment - Ah, this looks much better with 1.6.5. I now no longer have to set ${WORKSPACE}/Dockerfile - I can set just Dockerfile. Thanks! But it's worth noting that I now CANNOT set ${WORKSPACE}/Dockerfile. If I do that, it errors like this: {{Your project is missing a Dockerfile [ssh-agent] Stopped. FATAL: Interrupted java.lang.RuntimeException: Interrupted at com.cloudbees.jenkins.plugins.docker_build_env.DockerBuildWrapper.setUp(DockerBuildWrapper.java:171) at hudson.model.Build$BuildExecution.doRun(Build.java:156) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534) at hudson.model.Run.execute(Run.java:1738) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:410)}}

            People

            • Assignee:
              ndeloof Nicolas De Loof
              Reporter:
              johnl John Leach
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: