I'm trying to create a docker image with postgres AND some users, schema and data.
I don't want to use docker-entrypoint-initdb.d because database will be initialize in docker run step, i want all my data avalaible when docker run. So i'm trying to build an image with some users, schema and data, but i can't do that.
(I'm trying to do that for launching automated unit test who start my docker postgres Database. The purpose of this is to avoid data initialization and providing same docker database for all coworkers)
I have reading some doc about VOLUMES, data-container, etc... but it doesn't give a independent container I have tryed something like that, but no data were present when starting my container
FROM postgres:9.4
RUN mkdir -p /var/lib/pgdata RUN chown -R postgres /var/lib/pgdata ENV PGDATA /var/lib/pgdata VOLUME /var/lib/pgdata
COPY init_database.sql /init/init_database.sql
RUN /etc/init.d/postgresql start && pg_createcluster 9.4 main --start
USER postgres
RUN /etc/init.d/postgresql start &&\ psql --command "CREATE USER user0 WITH PASSWORD 'user0';"
USER root
Thanks for helping !