initdb:无法更改Postgresql容器上目录的权限 [英] initdb: could not change permissions of directory on Postgresql container

查看:2310
本文介绍了initdb:无法更改Postgresql容器上目录的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是docker生态系统的新手,我正在尝试使用yaml composer文件启动一个简单的postgres容器以及一个卷,以使其持久化其数据。该文件如下:

I am new to the docker ecosystem and I am trying to spin up a simple postgres container along with a volume so it persists its data, by using a yaml composer file. The file is as follows:

# Use postgres/example user/password credentials
version: '3.3'
services:
    db:
        image: postgres
        environment:
            POSTGRES_DB: recrow
            POSTGRES_USER: recrow
            POSTGRES_PASSWORD: recrow_db_1000
            PGDATA: /var/lib/pgsql/data/pgdata
        volumes:
          - ./pgsql/data:/var/lib/pgsql/data/pgdata

但是,调用 docker-compose -f stack.yml up 时,出现以下错误:

However, upon calling docker-compose -f stack.yml up I get the following error:


对现有目录的固定权限
/ var / lib / postgresql / data / pgdata ... initdb:无法更改
目录 / var / lib / postgresql / data / pgdata的权限:不允许操作

fixing permissions on existing directory /var/lib/postgresql/data/pgdata ... initdb: could not change permissions of directory "/var/lib/postgresql/data/pgdata": Operation not permitted

/ var / lib / pgsql / data / pgdata 应该是相对于容器根目录的目录,而 ./ pgsql / data 是主机上的路径。我正在从安装在 / mnt / storage 上的ntfs-3g分区运行容器。可能是什么问题呢?通过将我的用户添加到docker组中,我也正在运行没有root权限的docker,并且该用户还具有对前面提到的挂载点 / mnt / storage 的完全访问权限。

/var/lib/pgsql/data/pgdata is supposed to be a directory relative to the container's root, while ./pgsql/data is a path on the host. I am running the container from an ntfs-3g partition mounted on /mnt/storage. What could be the problem? I am also running docker without root permissions, by adding my user to the docker group and this user also has full access to the beforementioned mount point /mnt/storage.

推荐答案

我猜想这将与ntfs-3g不兼容。 PostgreSQL映像包含一个入口点脚本,该脚本在容器启动时进行了一些权限更改: https://github.com/docker-library/postgres/blob/972294a377463156c8d61297320c872fc7d370a9/9.6/docker-entrypoint.sh#L32-L38 。我在 https://找到了另一个相关问题askubuntu.com/questions/11840/how-do-i-use-chmod-on-an-ntfs-或-fat32-partition ,介绍了如何在安装时设置权限。但是无法通过 chmod chown 进行更改(在这种情况下,这可能是失败的原因)。

I'm guessing this is going to be an incompatibility with ntfs-3g. The PostgreSQL image contains an entrypoint script that is doing some permission changes on container start: https://github.com/docker-library/postgres/blob/972294a377463156c8d61297320c872fc7d370a9/9.6/docker-entrypoint.sh#L32-L38. I found another relevant question at https://askubuntu.com/questions/11840/how-do-i-use-chmod-on-an-ntfs-or-fat32-partition that talks about being able to set permissions at mount time. But not being able to change via chmod or chown (which is likely the reason for the failure in this case).

不幸的是,我认为这里的答案是,您不能安全地使用ntfs-3g来支持Docker主机卷装载。

Unfortunately, I think the answer here is that you cannot use ntfs-3g safely for backing Docker host volume mounts.

这篇关于initdb:无法更改Postgresql容器上目录的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆