【发布时间】:2016-10-21 02:05:18
【问题描述】:
我正在尝试让我的数据保留在 /home/me/redmine 中,以便当我的容器停止时,不会丢失数据。我使用的是官方的 postgres docker hub 镜像。
问题是,每次我启动 postgres 容器时,它都会立即退出。当我将“数据”附加到 /var/lib/postgresql 时,这个问题就开始了,否则,如果不添加“数据”,它就会启动,但我的数据没有被保存。另外,我的主机上的路径是/var/lib/postgresql/9.4/data,但是图像页面说使用/var/lib/postgresql/data。
这是我尝试从主机启动/挂载卷的方式:
docker run --name postgres -d \
--env='DB_NAME=redmine_production' \
--env='DB_USER=redmine' \
--env='DB_PASS=secret' \
--volume=/home/me/redmine/postgresql:/var/lib/postgresql/data \
postgres
...然后我将redmine链接如下...
docker run -d -p 3000:3000 --name redmine \
-v /home/me/redmine/files:/usr/src/redmine/files \
--link postgres:postgres redmine
在 redmine 容器中,/home/me/redmine/files 卷是一个单独的目录,我试图将文件保留在 Postgres 数据库中的文件之外。
编辑:
当我 cd 进入我的主机 /var/lib/postgresql 目录时,我在其中找到 9.4/data 然后看到所有者和组未在我的 /etc/passwd 或 /etc/groups 中列出,我想知道是否这与问题无关。
/var/lib/postgresql/9.4/data # ls -la
total 88
drwx------ 18 70 70 4096 Aug 13 2015 .
drwxr-xr-x 3 root root 4096 Mar 28 2015 ..
drwx------ 8 70 70 4096 Jul 2 2015 base
drwx------ 2 70 70 4096 Jul 2 2015 global
drwx------ 2 70 70 4096 Mar 28 2015 pg_clog
drwx------ 2 70 70 4096 Mar 28 2015 pg_dynshmem
lrwxrwxrwx 1 root root 31 Mar 28 2015 pg_hba.conf -> /etc/postgresql- 9.4/pg_hba.conf
lrwxrwxrwx 1 root root 33 Mar 28 2015 pg_ident.conf -> /etc/postgresql-9.4/pg_ident.conf
drwx------ 4 70 70 4096 Mar 28 2015 pg_logical
drwx------ 4 70 70 4096 Mar 28 2015 pg_multixact
drwx------ 2 70 70 4096 Jul 2 2015 pg_notify
drwx------ 2 70 70 4096 Mar 28 2015 pg_replslot
drwx------ 2 70 70 4096 Mar 28 2015 pg_serial
drwx------ 2 70 70 4096 Mar 28 2015 pg_snapshots
drwx------ 2 70 70 4096 Aug 13 2015 pg_stat
drwx------ 2 70 70 4096 Aug 13 2015 pg_stat_tmp
drwx------ 2 70 70 4096 Mar 28 2015 pg_subtrans
drwx------ 2 70 70 4096 Mar 28 2015 pg_tblspc
drwx------ 2 70 70 4096 Mar 28 2015 pg_twophase
-rw------- 1 70 70 4 Mar 28 2015 PG_VERSION
drwx------ 3 70 70 4096 Mar 28 2015 pg_xlog
-rw------- 1 70 70 88 Mar 28 2015 postgresql.auto.conf
lrwxrwxrwx 1 root root 35 Mar 28 2015 postgresql.conf -> /etc/postgresql-9.4/postgresql.conf
-rw------- 1 70 70 1626 Aug 13 2015 postmaster.log
-rw------- 1 70 70 114 Jul 2 2015 postmaster.opts
想法?
【问题讨论】:
标签: postgresql docker redmine