Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
remmelt opened this issue Oct 21, 2014 · 3 comments
Closed

Comments

@remmelt
Copy link

remmelt commented Oct 21, 2014

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.

@remmelt
Copy link
Author

remmelt commented Oct 21, 2014

OK, I fixed this by deleting the VirtualBox box, removing everything in ~/.boot2docker and doing

boot2docker init && boot2docker start && $(boot2docker shellinit)

This is a clean re-install of the boot2docker image.

By magic, it started working... weird.

@remmelt remmelt closed this as completed Oct 21, 2014
@yosifkit
Copy link
Member

Very weird indeed. Maybe the 1.3 b2d upgrade is not so smooth.

@myles-mcdonnell
Copy link

I had the same issue. Turned out that the VM disk was full (the docker share, run "df" to check). I resolved by cleaning up some old images. You may also increase the virtual disk size (see VirtualBox docs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants