title: Docker Python script can't find file
body: <p>I've successfully built a Docker container and copied my application's files into the container in the Dockerfile. However, I am trying to execute a Python script that references an input file (that was copied into the container during the Docker build). I can't seem to figure out why my script is telling me it cannot locate the input file. I am including the Dockerfile I used to build the container below, and the relevant portion of the Python script that is looking for the input file it cannot find. </p>
  
  <p>Dockerfile:</p>
  
  <pre><code>FROM alpine:latest
  
  RUN mkdir myapplication
  
  COPY . /myapplication
  
  RUN apk add --update \
      python \
      py2-pip &amp;&amp; \
      adduser -D aws
  
  WORKDIR /home/aws
  
  RUN mkdir aws &amp;&amp; \
      pip install --upgrade pip &amp;&amp; \
      pip install awscli &amp;&amp; \
      pip install -q --upgrade pip &amp;&amp; \
      pip install -q --upgrade setuptools &amp;&amp; \
      pip install -q -r /myapplication/requirements.txt
  
  CMD ["python", "/myapplication/script.py", "/myapplication/inputfile.txt"]
  </code></pre>
  
  <p>Relevant portion of the Python script:</p>
  
  <pre><code>if len(sys.argv) &gt;= 2:
      sys.exit('ERROR: Received 2 or more arguments. Expected 1: Input file name')
  
  elif len(sys.argv) == 2:
      try:
          with open(sys.argv[1]) as f:
              topics = f.readlines()
      except Exception:
          sys.exit('ERROR: Expected input file %s not found' % sys.argv[1])
  else:
      try:
          with open('inputfile.txt') as f:
              topics = f.readlines()
      except:
          sys.exit('ERROR: Default inputfile.txt not found. No alternate input file was provided')
  </code></pre>
  
  <p>Docker command on host resulting in error:</p>
  
  <pre><code>sudo docker run -it -v $HOME/.aws:/home/aws/.aws discursive python \
      /discursive/index_twitter_stream.py
  </code></pre>
  
  <p>The error from the command above:</p>
  
  <blockquote>
    <p>ERROR: Default inputfile.txt not found. No alternate input file  was provided</p>
  </blockquote>
  
  <p>The AWS stuff is drawn from a tutorial on how to pass your host's AWS credentials into the Docker container for use in interacting with AWS services. I used elements from here: <a href="https://github.com/jdrago999/aws-cli-on-CoreOS" rel="nofollow noreferrer">https://github.com/jdrago999/aws-cli-on-CoreOS</a></p>