gpt4 book ai didi

windows - Windows 上的 PostgreSQL docker 容器

转载 作者:IT老高 更新时间:2023-10-28 21:43:25 26 4
gpt4 key购买 nike

我一直在尝试在我的 Windows 机器上运行 PostgresSQL Docker 容器并安装数据卷,使用以下命令:

docker run -p 5432:5432 -it --volume c:\Users\me\Desktop\pg\data\:/var/lib/postgresql/data postgres:latest -e POSTGRES_USER=user POSTGRES_PASSWORD=password

但是,当容器尝试启动时,我不断收到权限被拒绝错误列表:

chown: changing ownership of ‘/var/lib/postgresql/data/pg_log’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_logical/mappings’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_logical/snapshots’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_logical’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_multixact/members/0000’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_multixact/members’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_multixact/offsets/0000’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_multixact/offsets’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_multixact’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_notify/0000’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_notify’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_replslot’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_serial’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_snapshots’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_stat’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_stat_tmp/db_0.stat’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_stat_tmp/db_16395.stat’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_stat_tmp/global.stat’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_stat_tmp’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_subtrans/0000’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_subtrans’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_tblspc’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_twophase’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/PG_VERSION’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_xlog/00000001000000000000000A’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_xlog/00000001000000000000000B’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_xlog/archive_status’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/pg_xlog’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/postgresql.auto.conf’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/postgresql.conf’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/postmaster.opts’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data/postmaster.pid’: Permission denied
chown: changing ownership of ‘/var/lib/postgresql/data’: Permission denied

谁能指出我做错了什么?

提前致谢。

最佳答案

这是 Docker for Windows 中的已知限制。从 Windows 目录到 Linux 目录的 Linux <-> Windows 文件系统映射语义是不完善的,因为挂载是使用 CIFS/SMB 完成的。其中一个不起作用的是 chown(更改所有者),因为它无法映射到您的 Windows 文件系统。

您可能应该改用命名卷。此论坛帖子有详细信息:https://forums.docker.com/t/data-directory-var-lib-postgresql-data-pgdata-has-wrong-ownership/17963/24?u=friism

关于windows - Windows 上的 PostgreSQL docker 容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43504238/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com