I\'m looking to build dockerfiles that represent company databases that already exist. Similarly, I\'d like create a docker file that starts by restoring a psql dump.
<
According to the usage guide for the official PostreSQL Docker image, all you need is:
FROM postgres
ENV POSTGRES_DB my_database
COPY psql_dump.sql /docker-entrypoint-initdb.d/
The POSTGRES_DB environment variable will instruct the container to create a my_database schema on first run.
And any .sql file found in the /docker-entrypoint-initdb.d/ of the container will be executed.
If you want to execute .sh scripts, you can also provide them in the /docker-entrypoint-initdb.d/ directory.