I'm trying to avoid touching a shared dev database in my workflow; to make this easier, I want to have Docker image definitions on my disk for the schemas I need. I'm stuck however at making a Dockerfile that will create a Postgres image with the dump already restored. My problem is that while the Docker image is being built, the Postgres server isn't running.
While messing around in the container in a shell, I tried starting the container manually, but I'm not sure what the proper way to do so. /docker-entrypoint.sh
doesn't seem to do anything, and I can't figure out how to "correctly" start the server.
So what I need to do is:
- start with "FROM postgres"
- copy the dump file into the container
- start the PG server
- run
psql
to restore the dump file - kill the PG server
(Steps I don't know are in italics, the rest is easy.)
What I'd like to avoid is:
- Running the restore manually into an existing container, the whole idea is to be able to switch between different databases without having to touch the application config.
- Saving the restored image, I'd like to be able to rebuild the image for a database easily with a different dump. (Also it doesn't feel very Docker to have unrepeatable image builds.)