我正在尝试在docker容器中运行postgresql,但当然我需要让我的数据库数据是持久的,所以我试图使用仅数据容器暴露卷来存储数据库在这个地方.
所以,我的数据容器有这样的Dockerfile:
FROM ubuntu # Create data directory RUN mkdir -p /data/postgresql # Create /data volume VOLUME /data/postgresql
我运行的是:
docker run --name postgresql_data lyapun/postgresql_data true
在我的postgresql.conf中我设置:
data_directory = '/data/postgresql'
然后我以这样的方式运行我的postgresql容器:
docker run -d --name postgre --volumes-from postgresql_data lyapun/postgresql
我得到了:
2014-07-04 07:45:57 GMT FATAL: data directory "/data/postgresql" has wrong ownership 2014-07-04 07:45:57 GMT HINT: The server must be started by the user that owns the data directory.
如何处理这个问题?我搜索了很多关于使用带有docker卷的postgresql的信息,但我没有找到任何东西.
谢谢!