Skip to content

"/var/lib/postgresql/data/pg_xlog/archive_status": Permission denied #26

Closed
@remmelt

Description

@remmelt

Under docker 1.3.0 and boot2docker 1.3.0 postgres:9.3 quits with the following error:

docker run --rm --name postgres --volume /Users/remmelt/postgres:/var/lib/postgresql/data postgres

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... initdb: could not create directory "/var/lib/postgresql/data/pg_xlog/archive_status": Permission denied
Boot2Docker-cli version: v1.3.0
Git commit: deafc19
Docker version 1.3.0, build c78088f

I think this is due to the new boot2docker volume support in 1.3.0. I can see the directory mounted in the boot2docker volume, they are owned by docker(1000)/staff.

$ id docker
uid=1000(docker) gid=50(staff) groups=50(staff),100(docker)

My local OSX user has id 501.

$ id remmelt
uid=501(remmelt) gid=20(staff)

Inside the postgres container, the postgres user has uid 999, and the directory is owned by an unknown user with uid 1000, probably inherited from boot2docker.
I cannot change the ownership of the mounted volume from inside the container, not even when using root.

I thought that a quick fix would be to give the postgres user uid 1000. This works in that the postgres user is now owner of the /var/lib/postgres/data directory and can create files, but it throws the following immediately after:

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in /var/lib/postgresql/data/base/1 ... LOG:  could not link file "pg_xlog/xlogtemp.22" to "pg_xlog/000000010000000000000001" (initialization of log file): Operation not permitted
FATAL:  could not open file "pg_xlog/000000010000000000000001": No such file or directory
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/data"

I see a comment on line 4 of the 9.3 Dockerfile that reads "# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added" so I don't know if you're doing any magic with the uid.

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