Sunday, June 14, 2015

Docker container cannot access mounted volumes in OSX host

If you are running Nginx or Apache in your docker images while using those to write files (ex. cache) on the host machine, chances are you will get a permission error.

Bash into your container:

> docker-compose run bash

cd into the location that has your mounted volume and do a "ls -l", you may see the following:

drwxr-xr-x 1 1000 staff 646 Jun 15 03:39 app

In Nginx or Apache, the user is usually www-data. We need to associate www-data with the UID 1000.

In your Dockerfile, add the following:

> RUN usermod -u 1000 www-data

Now if you check the permission again, you would see the correct user.

drwxr-xr-x 1 www-data staff 646 Jun 15 03:39 app

No comments:

Post a Comment