title: docker mounting volume with permission denied
body: <p>I am trying to setup a docker container that mounts a volume from the host. No matter what I try, it always says permission denied when I remote into the docker container. This is some of the commands I have tried adding to my docker file:</p>
  
  <pre><code>RUN su -c "setenforce 0"
  </code></pre>
  
  <p>and </p>
  
  <pre><code>chcon -Rt svirt_sandbox_file_t /app
  </code></pre>
  
  <p>Still I get the following error when I remote into my container:</p>
  
  <blockquote>
    <p>Error: EACCES: permission denied, scandir '/app'
        at Error (native)</p>
    
    <p>Error: EACCES: permission denied, open 'npm-debug.log.578996924'
        at Error (native)</p>
  </blockquote>
  
  <p>And as you can see, the app directory is assigned to some user with uid 1000:</p>
  
  <p><a href="https://i.stack.imgur.com/uedm5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uedm5.png" alt="enter image description here"></a></p>
  
  <p>Here is my docker file:</p>
  
  <pre><code>FROM php:5.6-fpm
  
  # Install modules
  RUN apt-get update &amp;&amp; apt-get install -y \
      git \
      unzip \
      libmcrypt-dev  \
      libicu-dev \
      mysql-client \
      freetds-dev \
      libxml2-dev
  
  RUN apt-get install -y freetds-dev php5-sybase
  
  # This symlink fixes the pdo_dblib install
  RUN ln -s /usr/lib/x86_64-linux-gnu/libsybdb.a /usr/lib/
  
  RUN    docker-php-ext-install pdo \
      &amp;&amp; docker-php-ext-install pdo_mysql \
      &amp;&amp; docker-php-ext-install pdo_dblib \
      &amp;&amp; docker-php-ext-install iconv \
      &amp;&amp; docker-php-ext-install mcrypt \
      &amp;&amp; docker-php-ext-install intl \
      &amp;&amp; docker-php-ext-install opcache \
      &amp;&amp; docker-php-ext-install mbstring
  
  # Override the default php.ini with a custom one
  COPY ./php.ini /usr/local/etc/php/
  
  # replace shell with bash so we can source files
  RUN rm /bin/sh &amp;&amp; ln -s /bin/bash /bin/sh
  
  # nvm environment variables
  ENV NVM_DIR /usr/local/nvm
  ENV NODE_VERSION 4.4.7
  
  # install nvm
  RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash
  
  # install node and npm
  RUN source $NVM_DIR/nvm.sh \
      &amp;&amp; nvm install $NODE_VERSION \
      &amp;&amp; nvm alias default $NODE_VERSION \
      &amp;&amp; nvm use default
  
  # add node and npm to path so the commands are available
  ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
  ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
  
  # confirm installation
  RUN node -v
  RUN npm -v
  
  # Install Composer
  RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
  RUN composer --version
  
  # Configure freetds
  ADD ./freetds.conf /etc/freetds/freetds.conf
  
  WORKDIR /app
  
  # Gulp install
  RUN npm install -g gulp
  RUN npm install -g bower
  
  
  CMD ["php-fpm"]
  </code></pre>
  
  <p>Here is my docker-compose:</p>
  
  <pre><code>nginx_dev:
    container_name: nginx_dev
    build: docker/nginx_dev
    ports:
      - "80:80"
    depends_on:
      - php_dev
    links:
      - php_dev
    volumes:
      - ./:/app
  
  
  php_dev:
    container_name: php_dev
    build: docker/php-dev
    volumes:
      - ./:/app`
  </code></pre>
  
  <p>Is there any commands I can run to give the root user permissions to access the app directory? I am using docker-compose as well.</p>