已安装(本地)的 Docker 和 Postgresql:chown:更改“/var/lib/postgresql/data/pgdata”的所有权:权限被拒绝

问题描述 投票:0回答:1

我使用以下标准将本地卷安装到我的 postgres 容器中,如下所述:https://hub.docker.com/_/postgres

$ docker run -d \
    --name some-postgres \
    -e POSTGRES_PASSWORD=mysecretpassword \
    -e PGDATA=/var/lib/postgresql/data/pgdata \
    -v /custom/mount:/var/lib/postgresql/data \
    postgres

几个月来它运行良好,但自从上次 docker 更新到 Docker 版本 27.3.1(构建 ce1223035a)以来,它不再工作了。我在 Mac 上使用 colima 和 docker 引擎。

当我现在运行相同的命令时,我收到以下错误消息:

chown:更改“/var/lib/postgresql/data/pgdata”的所有权:权限被拒绝

为什么以前可以用,现在却出现问题?据我了解,只要您遵循此处提到的标准,文档即可 --> https://github.com/docker-library/postgres/issues/361#issuecomment-490241136 一切都应该没问题。

有什么想法吗?

postgresql docker colima
1个回答
0
投票

我第一次看到你的评论是在 docker-library/postgres#361。经过进一步研究,我在 Colima repo 中找到了解决方案,here

解决方案如下:

# delete existing instance
colima delete 

# create a new instance with 'vz' instead of the default 'qemu'
# vz is macOS Virtualization.Framework
colima start --vm-type=vz

您还可以启用 Rosetta 2 仿真,以获得更好的 amd64 仿真性能:

colima start --vm-type=vz --vz-rosetta

或者,您可以将

colima template
与以下选项一起使用来设置默认选项,以避免将它们传递给
colima start
:

- vmType: qemu
+ vmType: vz

...

- rosetta: false
+ rosetta: true

...

# needed when using `colima start --edit`
# but, you can still set it for good measure even if not using --edit
- mountType: sshfs
+ mountType: virtiofs
© www.soinside.com 2019 - 2024. All rights reserved.