Adding permissions to host directory with docker-compose

I’m trying to set up a development environment using docker-compose
and my container does not seem to have permissions to the host directory
that is mounted to the container, i’m getting this error when running
a grunt task that tries to modify folders inside the volume:

app_1                   | Warning: Unable to delete ".tmp" file (EACCES, permission denied '.tmp'). Use --force to continue.

here’s my docker file:

  • Docker build argument
  • How to switch from ascii postgresql database to utf8 on docker?
  • Docker Alpine image + grpc: Warning: insecure environment read function 'getenv' used
  • Error while cleaning images from docker
  • Where are containers located in the host's file system?
  • How to set docker back to default configuration
  • FROM node:0.10
    RUN mkdir -p /usr/src/app
    WORKDIR /usr/src/app
    RUN apt-get update \
        && apt-get install -y --no-install-recommends ruby-sass \
        && rm -rf /var/lib/apt/lists/* \
        && apt-get clean -y \
        && apt-get autoremove -y
    RUN npm install -g grunt-cli bower
    RUN groupadd -r node \
    &&  useradd -r -m -g node node
    RUN chown -R node:node /usr/src/app
    USER node
    EXPOSE 8080

    and my docker-compose file:

      build: .
       - "9000:9000"
       - ./server/config/env/development.env
       - ./:/usr/src/app:Z
      command: bash -c "npm install && bower install && grunt dev && npm start"
       - "27017:27017"
    • I’m running ubuntu 15.10 with docker-compose version 1.5.2, build 7240ff3
    • Note that I am using the :Z permission

  • dial tcp: lookup no such host
  • Allow redeploy for “latest” docker tag in Nexus OSS
  • Running GUI in docker (no ssh, no VNC)
  • backports/lzma/_lzmamodule.c:115:18: fatal error: lzma.h: No such file or directory
  • Connect from web app to Oracle DB docker container
  • Why is JVM process RAM getting bigger (1GB+) even if my heap and non-heap are capped at 128M?
  • One Solution collect form web for “Adding permissions to host directory with docker-compose”

    It’s just a file permissions thing.

    The first thing to realise is that the volume you are mounting has different permissions to the folder you create and chown in the Dockerfile. The node user presumably doesn’t have permissions to access this folder. You can fix this by running something like:

    $ docker run -u root -v $(pwd):/usr/src/app:Z my_app_image chown -R node:node /usr/src/app

    This will change the permissions of the folder on the host.

    Alternatively, if you need to be root to run the npm install && bower install, you could leave the root user as the default user then change to the node user to run the application. Something like:

    npm install && bower install && gosu node npm start

    Here I’ve used the gosu tool, which you will need to install in the image. It’s a little nicer than sudo, as it doesn’t start a second process.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.