title: Dockerfile: added files won't be copied to volume
body: <p>I made a Dockerfile for a Python Script, which needs some persistent data in a volume. Problem is the files for the volume won't be in place in the container.</p>
  
  <p>Dockerfile:</p>
  
  <pre><code>FROM python:3
  
  COPY grab_immo /grab_immo
  
  RUN mkdir /data
  
  ADD ./data/contacts /data
  ADD ./data/run.log /data
  ADD ./data/template /data
  
  VOLUME /data
  
  WORKDIR /grab_immo
  
  RUN pip install -r requirements.txt
  
  ENV MY_ADDRESS=value \
      PASSWORD=value \
      SMTP_HOST=value \
      SMTP_PORT=value 
  
  CMD [ "python", "./main.py" ]
  </code></pre>
  
  <p>docker-compose.yml</p>
  
  <pre><code>---
  version: "2"
  services:
    grab_immo:
      build: .
      image: yyy/grab_immo
      container_name: grab_immo
      environment:
      - MY_ADDRESS = ''
      - PASSWORD = 
      - SMTP_HOST = 
      - SMTP_PORT = 587
      volumes:
        - /home/yyy/grab_immo_config:/data
      restart: unless-stopped
  </code></pre>
  
  <p>so I included this in the python file for troubleshooting:</p>
  
  <pre><code>print(os.path.isfile('/data/contacts') )    
  print(os.path.isdir('/data'))
  </code></pre>
  
  <p>docker-compose up gives me this:</p>
  
  <pre><code>grab_immo    | False   //print(os.path.isfile('/data/contacts') )
  grab_immo    | True    //print(os.path.isdir('/data'))
  grab_immo    | /grab_immo/main.py
  grab_immo    | Traceback (most recent call last):
  grab_immo    |   File "./main.py", line 248, in &lt;module&gt;
  grab_immo    |     main()
  grab_immo    |   File "./main.py", line 206, in main
  grab_immo    |     sendmail('asdf', 'asdf', 'asdfk', 'deskldf')
  grab_immo    |   File "./main.py", line 84, in sendmail
  grab_immo    |     names, emails = get_contacts(newPath + 'contacts') # read contacts
  grab_immo    |   File "./main.py", line 122, in get_contacts
  grab_immo    |     with open(filename, mode='r', encoding='utf-8') as contacts_file:
  grab_immo    | FileNotFoundError: [Errno 2] No such file or directory: '/data/contacts'
  grab_immo exited with code 1
  </code></pre>
  
  <p>docker inspect:</p>
  
  <pre><code>"Mounts": [
              {
                  "Type": "bind",
                  "Source": "/home/yyy/grab_immo_config",
                  "Destination": "/data",
                  "Mode": "rw",
                  "RW": true,
                  "Propagation": ""
              },
  </code></pre>
  
  <p>I created the directory on the hostmachine, but there was never a file in it.</p>
  
  <p>The image was built on a Win10 maschine, and I try to run it on a ubuntu server-vm.</p>
  
  <p>also I replaced the ADD commands with COPY, tried to copy the whole directory   et cetera.</p>
  
  <p>Since the os.path.isdir is true, I'm suspecting the mounting of the directory works. But somehow the expected files are not there...</p>
  
  <p>Thanks for any suggestions</p>