[英]Docker: ignore permission when create postgresql container
I created postgres container by run command in docker: 我在docker中通过运行命令创建了postgres容器:
docker run --name=pg-docker -p 5433:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=s123 postgres:11.5-alpine
In pg-docker
container /var/lib/postgresql/data has this permissions: 在pg-docker
容器中,/ var / lib / postgresql / data具有以下权限:
/ # ls -la $PGDATA
total 128
drwx------ 19 postgres postgres 4096 Sep 2 10:44 .
drwxr-xr-x 1 postgres postgres 4096 Aug 21 00:46 ..
-rw------- 1 postgres postgres 3 Sep 2 10:44 PG_VERSION
drwx------ 5 postgres postgres 4096 Sep 2 10:44 base
drwx------ 2 postgres postgres 4096 Sep 2 10:44 global
drwx------ 2 postgres postgres 4096 Sep 2 10:44 pg_commit_ts
drwx------ 2 postgres postgres 4096 Sep 2 10:44 pg_dynshmem
-rw------- 1 postgres postgres 4535 Sep 2 10:44 pg_hba.conf
-rw------- 1 postgres postgres 1636 Sep 2 10:44 pg_ident.conf
drwx------ 4 postgres postgres 4096 Sep 2 10:44 pg_logical
drwx------ 4 postgres postgres 4096 Sep 2 10:44 pg_multixact
drwx------ 2 postgres postgres 4096 Sep 2 10:44 pg_notify
drwx------ 2 postgres postgres 4096 Sep 2 10:44 pg_replslot
drwx------ 2 postgres postgres 4096 Sep 2 10:44 pg_serial
drwx------ 2 postgres postgres 4096 Sep 2 10:44 pg_snapshots
drwx------ 2 postgres postgres 4096 Sep 2 10:44 pg_stat
drwx------ 2 postgres postgres 4096 Sep 2 10:45 pg_stat_tmp
drwx------ 2 postgres postgres 4096 Sep 2 10:44 pg_subtrans
drwx------ 2 postgres postgres 4096 Sep 2 10:44 pg_tblspc
drwx------ 2 postgres postgres 4096 Sep 2 10:44 pg_twophase
drwx------ 3 postgres postgres 4096 Sep 2 10:44 pg_wal
drwx------ 2 postgres postgres 4096 Sep 2 10:44 pg_xact
-rw------- 1 postgres postgres 88 Sep 2 10:44 postgresql.auto.conf
-rw------- 1 postgres postgres 23841 Sep 2 10:44 postgresql.conf
-rw------- 1 postgres postgres 24 Sep 2 10:44 postmaster.opts
-rw------- 1 postgres postgres 94 Sep 2 10:44 postmaster.pid
/ # echo $PGDATA
/var/lib/postgresql/data
and it's log says The files belonging to this database system will be owned by user "postgres". This user must also own the server process.
日志The files belonging to this database system will be owned by user "postgres". This user must also own the server process.
The files belonging to this database system will be owned by user "postgres". This user must also own the server process.
Now when i want to use mount binding when created docker i got: 现在,当我想在创建docker时使用安装绑定时,我得到了:
running bootstrap script ... 2019-08-31 13:34:38.428 UTC [47] FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
2019-08-31 13:34:38.428 UTC [47] HINT: The server must be started by the user that owns the data directory.
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/data"
So i decided to ignore this permissions to send out data
directory from container to host. 因此,我决定忽略此权限以将data
目录从容器发送到主机。 I think i should write commend in dockerfile
.What is your suggestion ? 我想我应该在dockerfile
写出赞扬您的建议? I have no idea to implemented ignore permission! 我不知道实施忽略权限!
使用此命令在Linux上为我工作,也许这是Windows特定的问题?
docker run --name=pg-docker -p 5433:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=s123 -v /full/path/to/db_volumes/on/host/machine:/var/lib/postgresql/data postgres:11.5-alpine
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.