我正试图在OSX上用boot2docker
运行postgres
image的容器。
此命令在我的Ubuntu上运行良好:
docker run -v $(pwd)/data:/var/lib/postgresql/data postgres
但是OSX说:
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
没有帮助。
我尝试了选项--user$(id-u):$(id-g)
。它打破Ubuntu上的容器,并改变OSX上的错误。
Ubuntu:chmod:更改“/var/lib/postgresql/data”的所有权:不允许操作
由于它适用于Ubuntu,我想在OSX上运行它,而不需要创建自己的图像。但我不知道如何处理这个错误。
有什么想法吗?
我认为这是一个已知的boot2docker问题,有几个解决方法,但没有解决方案
#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
将本地文件夹装入docker容器不是一个好做法。它经常导致文件权限出现问题。
更好的解决方案是使用卷容器更改设置。还有一些很好的卷容器备份概念。