title: Docker: RUN touch doesn't create file
body: <p>While trying to debug a RUN statements in my Dockerfile, I attempted to redirect output to a file in a bound volume (<code>./mongo/log</code>).</p>
  
  <p>To my surprise I was unable to create files via the RUN command, or to pipe the output of another command to a file using the redirection/appending (<code>&gt;</code>,<code>&gt;&gt;</code>) operators. I was however able to perform the said task by logging in the running container via <code>docker exec -ti mycontainer /bin/sh</code> and issuing the command from there.</p>
  
  <p>Why is this behaviour happening? How can I touch file in the Dockerfile / redirect output to a file or to the console from which the Dockerfile is run?</p>
  
  <p>Here is my Dockerfile:</p>
  
  <pre><code>FROM mongo:3.4
  
  #Installing NodeJS
    RUN apt-get update &amp;&amp; \
      apt-get install -y curl &amp;&amp; \
      curl -sL https://deb.nodesource.com/setup_6.x | bash - &amp;&amp; \
      apt-get install -y nodejs
  
  
  #Setting Up Mongo
    WORKDIR /var/www/smq
    COPY ./mongo-setup.js mongo-setup.js
  
    ##for testing
    RUN touch /var/log/node.log &amp;&amp; /
        node --help 2&gt;&amp;1 &gt; /var/log/node.log
  
    ##this was the command to debug
    #RUN node mongo-setup.js &gt; /var/log/mongo-setup.log 2&gt; /var/log/mongo-setup.error.log
  </code></pre>
  
  <p>Here an excerpt from my docker-compose.yml:</p>
  
  <pre><code>mongodb:
      build:
        context: ./
        dockerfile: ./mongodb-dockerfile
      container_name: smqmongodb
      volumes:
       - /var/lib/mongodb/data
       - ./mongo/log/:/var/log/
       - ../.config:/var/www/.config
  </code></pre>