user606521
user606521

Reputation: 15424

Volume on host - permission denied for Postgres (Mac OS)

I am starting Postgresql image with following volume

/Users/me/Desktop/volumes/postgresql/data:/var/lib/postgresql/data

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?

Upvotes: 3

Views: 4058

Answers (2)

Alessander Franca
Alessander Franca

Reputation: 2753

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:

/Users/me/Desktop/volumes/postgresql/data

to

/root/data

Enter at the Docker at Virtual Box and create the data folder

Upvotes: 0

christian
christian

Reputation: 10198

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>

Upvotes: 3

Related Questions