Reputation: 701
I'm trying to run the container of postgres
image with boot2docker
on OSX.
This command works well on my Ubuntu:
docker run -v $(pwd)/data:/var/lib/postgresql/data postgres
but OSX says:
fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... initdb: could not create directory "/var/lib/postgresql/data/global": Permission denied
initdb: removing contents of data directory "/var/lib/postgresql/data"
chmod
doesn't help.
I've tried option --user $(id -u):$(id -g)
. It breaks container on Ubuntu, and it changes the error on OSX.
Ubuntu: chmod: changing ownership of ‘/var/lib/postgresql/data’: Operation not permitted
OSX: chmod: changing permissions of ‘/run/postgresql’: Operation not permitted
As it works for Ubuntu I want to run it on OSX, without creating my own images. But I have no idea how to deal with this error.
Any ideas?
Upvotes: 4
Views: 977
Reputation: 1330
I think this is a known boot2docker issue There's several workarounds but no solution there
#1) Overriding the /Users default share on boot2docker start:
boot2docker --vbox-share=$(pwd)/share-location=share-name up
#2) boot2docker ssh in and mount the custom share:
sudo mount -t vboxsf -o uid=999,gid=50 share-name [SHARE-FULL-PATH]/share-location
Upvotes: 2
Reputation: 54212
Mounting local folders into docker containers is not a good practice. It quite often results into problems with file permissions.
The better solution would be to change your setup using a volume container instead. There are also good concepts for volume container backups.
Upvotes: 1