title: What directory does a Docker build start in?
body: <p>I have a Dockerfile that has, amongst other directives, the following:</p>
  
  <pre><code>FROM node:alpine
  RUN cd /tmp &amp;&amp; \
    # several lines downloading/installing packages from zips
  
  ...
  
  ADD src/config.json /myapp/config.json
  
  WORKDIR /myapp
  </code></pre>
  
  <p>This is intended to be run from the root of the application repository to build the docker container. The <code>RUN</code> command is placed early because it's getting the application dependencies and this logically should occur early in the process. (It is also chaining a bunch of commands together in order to keep the number of layers low.) However, the <code>ADD</code> command expects to be in the same location as the Dockerfile - the root of the repository.</p>
  
  <p>Given that, is there a way to 'remember' where the docker build started from, and use this to orient the <code>ADD</code>? (Specifically, running this in a local dev environment will have a different <code>whereami</code> when building than my build server.) Or am I stuck with interleaving these commands, first copying the configuration over, then downloading dependencies, and so on?</p>
  
  <p>When I build, I am doing this from the root directory of my project (that contains a <code>src</code> folder):</p>
  
  <pre><code>docker build -t myapp:dev .
  </code></pre>
  
  <p>The error I get is:</p>
  
  <blockquote>
    <p>lstat src/config.json: no such file or directory</p>
  </blockquote>
  
  <p>If I insert <code>RUN pwd</code> the docker build reports it as being <code>/</code>, but I don't know if this is what it considers it's 'context' (that is, any <code>ADD</code> commands are relative to the <code>pwd</code>).</p>