Skip to content

Failing chmod of data mount in entrypoint when running rootless docker with specified --user #802

Closed
@raqbit

Description

@raqbit

I'm trying to use the postgress docker image in the rootless docker daemon mode, which means that the entire docker daemon runs inside of a user namespace.

As expected, when I use this mode and mount a local directory, the local directory is owned by an arbitrary high user id (100069), which is mapped to root (uid 0) in the container. But when I then try to change the userid the container runs with to my own host user with --user 1000 (or user: 1000 in compose), the container gets stuck failing to chmod the data directory in the docker-entrypoint.sh:

chmod: /var/lib/postgresql/data: Operation not permitted

I think this error is coming from

chmod 700 "$PGDATA"
(or the non-alpine entrypoint)

but I don't understand why. I verified that the user inside the container is indeed 1000 by replacing the command with id.


Command which can be run with docker rootless mod to reproduce the issue:

docker run --user 1000 -v "$PWD/data:/var/lib/posgresql/data" postgres:alpine

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions