Load Postgres dump after docker-compose up
Reading https://hub.docker.com/_/postgres/, the section 'Extend this image' explains that any .sql in /docker-entrypoint-initdb.d will be executed after build.
I just needed to change my Dockerfile.db to:
FROM postgresADD ./devops/db/dummy_dump.sql /docker-entrypoint-initdb.d
And it works!
sudo docker exec postgres psql -U postgres my_db_name < dump.sql
You can use pg_restore
inside the container:
cat ${BACKUP_SQL_File} | docker exec -i ${CONTAINER_NAME} pg_restore \ --verbose \ --clean \ --no-acl \ --no-owner \ -U ${USER} \ -d ${DATABASE}