首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Docker:创建postgresql容器时忽略权限

Docker:创建postgresql容器时忽略权限
EN

Stack Overflow用户
提问于 2019-09-02 19:43:38
回答 1查看 560关注 0票数 1

我在docker中通过run命令创建了postgres容器:

代码语言:javascript
运行
复制
 docker run  --name=pg-docker -p 5433:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=s123 postgres:11.5-alpine   

pg-docker容器中,/var/lib/postgresql/data拥有以下权限:

代码语言:javascript
运行
复制
/ # 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   

日志上写着The files belonging to this database system will be owned by user "postgres". This user must also own the server process.

现在,当我想在创建docker时使用挂载绑定时,我得到了:

代码语言:javascript
运行
复制
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"                      

所以我决定忽略这个权限,将data目录从容器发送到主机。我想我应该在dockerfile中写commend .What是你的建议吗?我不知道如何实现忽略权限!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-02 22:41:17

我在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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57756372

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档