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

Allow to use the docker build --file option when building an image

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Labels:
      None
    • Environment:
      Jenkins 1.6.10
      CloudBees Docker Build and Publish plugin version 1.0
      Ubuntu 14.04
    • Similar Issues:

      Description

      Allow to use the docker build --file option when building an image

      We would like to NOT have the Dockerfile at the root of the project, and have everything docker related in a subfolder "docker".

      Then we would build the image with
      docker build -t myrepo/myproject:v01 --file docker/Dockerfile .
      '.' is the docker context, meaning even though the Dockerfile is in a subfolder 'docker', docker can still access everything under '.' (the root of the project).
      It is not possible otherwise to access folders outside of the context, in a Dockerfile (using
      ADD../src/myfile.jar /srv/lib/myfile.jar
      ,for example. '..' is not allowed).

      So it would be nice to still have the options, in the GUI:

      • "Directory Dockerfile is in" (equivalent of "--file <path>)
      • "Docker context".

      Note:
      In the code, this seems to be in function buildAndTag() in file:

      src/main/java/com/cloudbees/dockerpublish/DockerBuilder.java

      {{String context = defined(getDockerfilePath()) ?
      getDockerfilePath() : ".";

      lastResult = executeCmd("docker build -t " + i.next()
      + ((isNoCache()) ? " --no-cache=true " : "") + " "
      + ((isForcePull()) ? " --pull=true " : "") + " "
      + context);}}

      The line
      {{String context = defined(getDockerfilePath()) }}
      should be changed so that DockerfilePath is not the same as context. Those should be different things.

        Attachments

          Activity

          Hide
          qnerden Quentin Nerden added a comment -

          Looking at the screenshot under "How to use" in the jenkins wiki:
          https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Docker+Build+and+Publish+plugin
          shows a textbox called Build Context.
          This seems to be this feature.
          Was it part of the plugin and then removed?

          Show
          qnerden Quentin Nerden added a comment - Looking at the screenshot under "How to use" in the jenkins wiki: https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Docker+Build+and+Publish+plugin shows a textbox called Build Context. This seems to be this feature. Was it part of the plugin and then removed?
          Hide
          guss77 Oded Arbel added a comment -

          That was already implemented. The text box is called "Dockerfile Path"

          Show
          guss77 Oded Arbel added a comment - That was already implemented. The text box is called "Dockerfile Path"

            People

            Assignee:
            csanchez Carlos Sanchez
            Reporter:
            qnerden Quentin Nerden
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated: