【Docker】Docker for windows 搭建 Postgresql 时数据持久化问题
操作系统:Windows10
工具:Docker for windows
数据库:Postgresql 11
docker run --name pg -d -e POSTGRES_PASSWORD=123 -v e:/docker_data/pg:/var/lib/postgresql/data -p 5432:5432 postgres
启动后挂载文件夹生成了相应的文件,但会提示权限问题终止,之前已经做了共享设置。
2018-08-14 03:19:29.050 UTC [1] FATAL: data directory "/var/lib/postgresql/data" has wrong ownership2018-08-14 03:19:29.050 UTC [1] HINT: The server must be started by the user that owns the data directory.
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... initdb: could not fsync file "/var/lib/postgresql/data/base/1": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/base/12993": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/base/12994": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/base": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/global": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_commit_ts": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_dynshmem": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_logical/mappings": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_logical/snapshots": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_logical": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_multixact/members": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_multixact/offsets": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_multixact": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_notify": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_replslot": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_serial": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_snapshots": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_stat": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_stat_tmp": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_subtrans": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_tblspc": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_twophase": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_wal/archive_status": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_wal": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_xact": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_tblspc": Invalid argument
ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
pg_ctl -D /var/lib/postgresql/data -l logfile start
waiting for server to start....2018-08-14 03:20:27.013 UTC [39] FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
2018-08-14 03:20:27.013 UTC [39] HINT: The server must be started by the user that owns the data directory.
stopped waiting
pg_ctl: could not start server
Examine the log output.
回答
试试加上-e PGDATA=/tmp 参考https://forums.docker.com/t/d...
或者试试执行docker volume create --name gitlab-postgresql -d local 然后docker compose这么写
services: postgresql:
restart: always
image: sameersbn/postgresql:9.5-1
volumes:
- gitlab-postgresql-volume:/var/lib/postgresql:Z
volumes:
gitlab-postgresql-volume:
external: true
用惯了compose, 转命令这个你自己转吧
参考https://forums.docker.com/t/t...
以上是 【Docker】Docker for windows 搭建 Postgresql 时数据持久化问题 的全部内容, 来源链接: utcz.com/a/74577.html