We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
Great article. One question: does this image persists the database state when it is shutdown or the modifications are gone and the image will always start only with the preloaded data?
Hey Rodrigo, thanks for the feedback!
Good question. Persisting the data does not depend on the image but how you run the container. The way I executed on the article does not save persist the data because the container is ephemeral (--rm every time we stop the container it will be deleted)
$ docker container run -d --rm -p 5432:5432 -e POSTGRES_PASSWORD=postgres -e POSTGRES_USER=postgres --name test_preloaded_db preloaded_db:latest
To persist the data you need to use a Docker Volumes https://docs.docker.com/sto... like this with docker compose.
[tmp] cat docker-compose.yml
version: "3.9"
services:
db:
image: preloaded_db:latest
restart: always
ports:
- 5434:5432
environment:
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata:
Thanks for sharing this approach! Really helped me reducing my container startup times. Using a large 519MB dump has some disadvantages 😄
Thank you so much! I was trying to figure out how to do this all afternoon.