Volume on host – permission denied for Postgres (Mac OS)
I am starting Postgresql image with following volume
According to docker docs it should work as docker should have access to
/Users directory on Mac OS. After creating & runing container I can see
that empty directory
/Users/me/Desktop/volumes/postgresql/data is created however Postgres does not start and show these lines in log:
could not create directory "/var/lib/postgresql/data/global": Permission denied
What I am doing wrong?
2 Solutions collect form web for “Volume on host – permission denied for Postgres (Mac OS)”
Your directory belongs to a different User then the user, that the User that executes the container.
Could you change your directory like that for a start.
chmod 777 /Users/me/Desktop/volumes/postgresql/data
If you can start your container with this setting, then this missing permissions are the root cause.
You could then try to start your container with
run -u uid ...
and specify the userid of your user on macos.
You have to create the user in boot2docker too, i.e.
boot2docker ssh sudo sh adduser <anyuserid> -u <your uid>
I had the same problem.
What I done was the workaround by creating the folder inside the Virtual Box.
Set your docker-compose.yml postgresql folder:
Enter at the Docker at Virtual Box and create the data folder