Answers: <p>I was tripping myself up: when I was trying the <code>--user</code> flag, I still had <code>--userns-remap</code> set. Running the daemon without <code>--userns-remap</code> did the trick.</p>
  
Answers: CC BY-SA 4.0
Answers: 2018-12-12T12:46:29.723Z
Answers: 2018-12-12T14:08:16.557Z
Answers: 2018-12-12T14:08:16.557Z
Answers: aryzing
Body: <p>I'm using Docker namespaces in an effort to allow files created within a volume to be arbitrarily read and written to by both the container user and the host user (please let me know if this is even a valid approach to what I'm trying to do!).</p>
  
  <p>My host username is <code>aryzing</code>. So I'm running the docker deamon as</p>
  
  <pre><code>dockerd --userns-remap=aryzing
  </code></pre>
  
  <p>The volume maps my host's <code>~/workspace/app</code> to the volume's <code>/usr/src/app</code>.</p>
  
  <p>From the host system I have no issue modifying the files, but from within the container, I have access errors. Specifically, I'm running NPM's install command from within the container, <code>npm install</code>, and it's unable to install the packages due to a permissions error:</p>
  
  <pre><code>Error: EACCES: permission denied, access '/usr/src/app/node_modules'
  </code></pre>
  
  <p>As per <a href="https://devops.stackexchange.com/questions/2342/using-docker-with-users-leaves-files-belonging-to-the-subuid-subgid">this post</a> I've also tried running the container with the <code>--user</code> flag, and ran into the same issue.</p>
  
  <p>Any suggestions on how to achive the functionality I'm after?</p>
  
Tags: <docker><linux><npm>
Title: How can container user and host user both have access to same files in volume?
UserDisplayName: aryzing
ThreadText: # How can container user and host user both have access to same files in volume?
  
  (Asked by: username_0 on 2018-12-12)
  
  I'm using Docker namespaces in an effort to allow files created within a volume to be arbitrarily read and written to by both the container user and the host user (please let me know if this is even a valid approach to what I'm trying to do!).
  
  My host username is `username_0`. So I'm running the docker deamon as
  
  ```
  dockerd --userns-remap=username_0
  
  ```
  
  The volume maps my host's `~/workspace/app` to the volume's `/usr/src/app`.
  
  From the host system I have no issue modifying the files, but from within the container, I have access errors. Specifically, I'm running NPM's install command from within the container, `npm install`, and it's unable to install the packages due to a permissions error:
  
  ```
  Error: EACCES: permission denied, access '/usr/src/app/node_modules'
  
  ```
  
  As per [this post](https://devops.stackexchange.com/questions/2342/using-docker-with-users-leaves-files-belonging-to-the-subuid-subgid) I've also tried running the container with the `--user` flag, and ran into the same issue.
  
  Any suggestions on how to achive the functionality I'm after?
  
  **Tags:** docker, linux, npm
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-12-12. Score: 2
  
  I was tripping myself up: when I was trying the `--user` flag, I still had `--userns-remap` set. Running the daemon without `--userns-remap` did the trick.
  
  
  ---
  
  