Bootstrap - docker-entrypoint-initdb.d
See installation.md on how to use bootstrap files with docker
- The official
postgresimage (alsomysql,mongo) runs any*.sql,*.sql.gz,*.shfiles dropped in/docker-entrypoint-initdb.d/on startup, in alphabetical order - Files are mounted in via a volume or baked in with
COPYin a Dockerfile Only runs once— when the data directory ($PGDATA) is empty on first boot. If the volume already holds data, the scripts aresilently skipped-
So editing a script and restarting does nothing; you must wipe the volume (
docker compose down -v) to re-run -
This is
not a migration system— it is a one-time bootstrap / seed: - no version tracking, no
up/down, no re-running, no rollback - it cannot evolve an existing database — only initialise a fresh one
- Good for: local dev, CI, and seeding demo data
- For anything long-lived, run a real migration tool (Flyway, Alembic, …) against the container after it starts — keep
initdb.dfor the initial empty-DB bootstrap only