title: Redirecting command output in docker
body: <p>I want to do some simple logging for my server which is a small Flask app running in a Docker container.</p>
  
  <p>Here is the Dockerfile</p>
  
  <pre><code># Dockerfile
  FROM dreen/flask
  MAINTAINER dreen
  WORKDIR /srv
  
  # Get source
  RUN mkdir -p /srv
  COPY perfektimprezy.tar.gz /srv/perfektimprezy.tar.gz
  RUN tar x -f perfektimprezy.tar.gz
  RUN rm perfektimprezy.tar.gz
  
  # Run server
  EXPOSE 80
  CMD ["python", "index.py", "1&gt;server.log", "2&gt;server.log"]
  </code></pre>
  
  <p>As you can see on the last line I redirect stderr and stdout to a file. Now I run this container and shell into it</p>
  
  <pre><code>docker run -d -p 80:80 perfektimprezy
  docker exec -it "... id of container ..." bash
  </code></pre>
  
  <p>And observe the following things:</p>
  
  <p>The server is running and the website working</p>
  
  <p>There is no <code>/srv/server.log</code></p>
  
  <p><code>ps aux | grep python</code> yields:</p>
  
  <pre><code>root         1  1.6  3.2  54172 16240 ?        Ss   13:43   0:00 python index.py 1&gt;server.log 2&gt;server.log
  root        12  1.9  3.3 130388 16740 ?        Sl   13:43   0:00 /usr/bin/python index.py 1&gt;server.log 2&gt;server.log
  root        32  0.0  0.0   8860   388 ?        R+   13:43   0:00 grep --color=auto python
  </code></pre>
  
  <p>But there are no logs... HOWEVER, if I <code>docker attach</code> to the container I can see the app generating output in the console.</p>
  
  <p>How do I properly redirect stdout/err to a file when using Docker?</p>