【发布时间】:2017-02-10 03:14:49
【问题描述】:
我一直在我的 Vagrant 机器(盒子是 ubuntu 14.04)上运行我的 docker 镜像,没有任何大问题。但是下面的错误让我绞尽脑汁。我希望你们能帮助我。
当我运行这个时:
$ docker run -it -v /vagrant/postgresql/data:/var/lib/postgresql/data postgres:9.2
我收到此错误
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
fixing permissions on existing directory /var/lib/postgresql/data ... ok
initdb: could not create directory "/var/lib/postgresql/data/pg_xlog": Permission denied
initdb: removing contents of data directory "/var/lib/postgresql/data"
vagrant@legionat:/vagrant/sonarqube$ docker run -it -v /vagrant/postgresql/data:/var/lib/postgresql/data postgres:9.2
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
fixing permissions on existing directory /var/lib/postgresql/data ... ok
initdb: could not create directory "/var/lib/postgresql/data/pg_xlog": Permission denied
initdb: removing contents of data directory "/var/lib/postgresql/data"
我尝试打开 /vagrant/postgresql 的所有权限,但没有成功。也许这是官方docker镜像的问题。
编辑:
我刚刚注意到很多人和我面临同样的问题:https://github.com/docker-library/postgres/issues/26
而且,正如有人在 cmets 中询问的那样,这里是这样的:
$ ls -l /vagrant/postgresql/data
total 0
【问题讨论】:
-
你的主机是什么操作系统?我假设 /vagrant 从那里安装到 VM 中?你能把
ls -l /vagrant/postgresql/data的输出贴在VM里面吗? -
@sprkysnrky 已编辑!
标签: postgresql docker permissions ubuntu-14.04