title: Mounting NFS shares inside docker container using shell script
body: <p>I have an Ubuntu container running on a windows host. I have all of the nfs client packages installed. I can connect to my container and mount an nfs share.</p>
  
  <p>The idea is it start the container run my script have it mount two shares and then run gunicorn.</p>
  
  <pre><code>docker-compose.yml
  version: '2.1'
  
  services:
    web:
    #  restart: always
      build: .
      expose:
        - "5000"
        - "80"
      ports:
        - "5000:80"
  
      #command: gunicorn -w 4 wsgi_mount:app -b 0.0.0.0:80 --timeout 500
      privileged: true
      command: /bin/bash /app/entrypoint.sh
  
  entrypoint.sh
  ------------
  mount --verbose -t nfs -o nolock -o nfsvers=3 server:/nfs/share /app/path_to_mount1
  mount --verbose -t nfs -o nolock -o nfsvers=3 server:/nfs/share /app/path_to_mount2
  gunicorn -w 4 wsgi_mount:app -b 0.0.0.0:80 --timeout 500
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>does not existt point /app/path_to_mount1
   does not existt point /app/path_to_mount2
  [2017-10-04 16:29:57 +0000] [41] [INFO] Starting gunicorn 19.7.1
  [2017-10-04 16:29:57 +0000] [41] [INFO] Listening at: http://0.0.0.0:80 (41)
  [2017-10-04 16:29:57 +0000] [41] [INFO] Using worker: sync
  [2017-10-04 16:29:57 +0000] [46] [INFO] Booting worker with pid: 46
  [2017-10-04 16:29:57 +0000] [49] [INFO] Booting worker with pid: 49
  [2017-10-04 16:29:57 +0000] [50] [INFO] Booting worker with pid: 50
  [2017-10-04 16:29:57 +0000] [53] [INFO] Booting worker with pid: 53
  </code></pre>
  
  <p>What i find really frustrating is if i just have it run gunicorn then attach to the container and copy past the line from the script in the container for each mount point it works. </p>
  
  <p>If i run the script inside the container i get the same exact error</p>
  
  <p>I know the privileges are right, i now NFS is setup correctly, and i can manually make it work in my container but if try and do it from a bash script inside the container running the exact same commands i get "does not existt point ..."  BTW the existt is not a typo it displays that way in the console.</p>
  
  <p>EDIT:
  The accepted answer worked perfectly but i just want to add here that if the path exists in the container already then it won't mount. Also want to add that changing the yml file if you define the mount in the docker-compose file will not recreate it if its bad you have to rm the volume first.</p>