I have a data container with Dockerfile:
from ubuntu:latest
VOLUME ["/var/lib/postgresql/9.3/main"]
and a postgresql service container:
#install stuff
............
# Set the default command to run when starting the container
CMD ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/var/lib/postgresql/9.3/main", "-c", "config_file=/etc/postgresql/9.3/main/postgresql.conf"]
then I start the data container and postgresql container:
docker run -i -t -d --name data docker:data
docker run -i -t -p 49131:5432 --name postgresql --volumes-from data --rm docker:postgresql
it says :
FATAL: data directory "/var/lib/postgresql/9.3/main" has wrong ownership
HINT: The server must be started by the user that owns the data directory.
it seems like the /var/lib/postgresql/9.3/main folder belong to the root user in the data container. Then i attach to the container, add user and change owner of that folder to postgres:
docker attach data
useradd postgres -s /bin/bash
chown -R postgres:postgres /var/lib/postgresql
then try again with the same error.
what is the problem and what am i missing?