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

Docker build from Dockerfile requires full path to Dockerfile

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • Docker version 1.9.1.
      Jenkins ver. 1.645
      CloudBees Docker Custom Build Environment Plugin 1.6.4

      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?)

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

              Created:
              Updated:
              Resolved: