Reputation: 943
I have a custom Dockerfile based on centos:latest
that installs software I need to run the web framework I use. I want to extend this Dockerfile so that I can add PostgreSQL, the catch being that I want to change pgsql's default data location from /var/lib/pgsql
to /var/www/data/pgsql
, which is a filesystem-mounted volume. I'm not sure if it is possible to do this in the Dockerfile or if I need to run some script afterwards from within a container. Any help would be appreciated.
Upvotes: 0
Views: 51
Reputation: 4677
Ultimately you need to change data_directory
in postgresql.conf. The default location for this in postgresql 9.5 is /etc/postgresql/9.5/main/postgresql.conf
.
This might look like:
data_directory = '/var/www/data/pgsql'
COPY postgresql.conf /etc/postgresql/9.5/main/postgresql.conf
, which will move your altered postgresql.conf into the container, and replace the default postgresql.conf. This is assuming PG 9.5 default install location in the container.Now when you run postgres, it should use your conf file with the /var/www/data/pgsql
data directory.
edit: about moving data_directory
Upvotes: 1