title: How to copy files from an absolute path to docker image using docker maven plugin
body: <p>I am writing microservices with Java. At the end, I run maven build to generate a Docker image based on a Dockerfile in directory [project-root]/docker. Some files need to be copied into the Docker image. Therefore I have the following lines in my Dockerfile:</p>
  
  <pre><code># HDFS base image
  FROM mdouchement/hdfs
  COPY ${workdir.name} /${workdir.name}
  COPY ${resource.dir} /etc/hadoop
  </code></pre>
  
  <p>Variables <code>workdir.name</code> and <code>resource.dir</code> are defined in pom.xml</p>
  
  <pre><code>&lt;properties&gt;
          &lt;workdir.name&gt;javarun&lt;/workdir.name&gt;
          &lt;resource.dir&gt;${project.baseUri}/src/main/resources&lt;/resource.dir&gt;
  &lt;/properties&gt;
  </code></pre>
  
  <p>While first copy command uses relative path which is equivalent to <code>target/docker/javarun</code>, second command uses absolute path.</p>
  
  <p>It turns out the first <code>COPY</code> works while I got error for the second <code>COPY</code> saying the directory is not found:</p>
  
  <pre><code>[INFO] Building image docker.repo.lgc.com/distarch/com.lgc.dist.core.msp.service.hdfs
  Step 1/3 : FROM mdouchement/hdfs
   ---&gt; c95344e8749d
  Step 2/3 : COPY javarun /javarun
   ---&gt; e2e8cb5bc21f
  Removing intermediate container f49da68fe77e
  Step 3/3 : COPY file:/C:/Users/H184870/Workspace/core/com.lgc.dist.core.msp.service.hdfs//src/main/resources /etc/hadoop
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 14.906 s
  [INFO] Finished at: 2017-04-20T11:07:12-05:00
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.3.10:build (docker-build) on project com.lgc.dist.core.msp.service.hdfs: 
  Exception caught: lstat file:/C:/Users/H184870/Workspace/core/com.lgc.dist.core.msp.service.hdfs//src/main/resources: no such file or directory -&gt; [Help 1]
  </code></pre>
  
  <p>The path printed out is <code>/C:/Users/H184870/Workspace/core/com.lgc.dist.core.msp.service.hdfs//src/main/resources</code> which looks weird. My guess is this is not a valid Windows path.</p>
  
  <p>I am running it on a Windows machine now, but the build process will eventually moved to a Linux server. How do I make an absolute path compatible with both OS when copying files in Dockerfile?</p>
  
  <p><strong>EDIT</strong>  Originally thought it was a windows path issue, so tried to build it on Linux and got the same error. </p>
  
  <p>According to <a href="https://github.com/moby/moby/issues/4592#issuecomment-282702580" rel="nofollow noreferrer">this post</a>, the src path should be the relative path from build context. That's why the absolute path does not work. But what is the default <code>PATH</code> of docker build? Is it the same as the directory where Dockerfile is located?</p>