According to the usage guide for the official PostreSQL Docker image, all you need is:
ENV POSTGRES_DB my_database
COPY psql_dump.sql /docker-entrypoint-initdb.d/
POSTGRES_DB environment variable will instruct the container to create a
my_database schema on first run.
.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
- How to persist data in a dockerized postgres database using volumes
- Docker – How can run the psql command in the postgres container?
- Remove a named volume with docker-compose?
- Changing a postgres containers server port in Docker Compose
- Docker-compose environment variables
- Using docker-compose to create tables in postgresql database
- How to fix error “Error: Database is uninitialized and superuser password is not specified.”
- Multiple databases in docker and docker-compose
- Postgres shuts down immediately when started with docker-compose
- How to use volume in docker compose for postgres?
- What’s the difference between Docker Compose vs. Dockerfile
- Connecting to Postgresql in a docker container from outside
- An error, “failed to solve with frontend dockerfile.v0”
- How to pass arguments to a Dockerfile?
- How to customize the configuration file of the official PostgreSQL Docker image?
- Docker-compose check if mysql connection is ready
- Docker – image operating system “windows” cannot be used on this platform
- docker-compose, run a script after container has started?
- E: Package ‘mysql-client’ has no installation candidate in php-fpm image build using docker compose
- What is the difference between `docker-compose build` and `docker build`?
- How to correctly link php-fpm and Nginx Docker containers?
- How to pass environment variable to docker-compose up
- How to pass arguments within docker-compose?
- Docker COPY from ubuntu absolute path
- How to mount local volumes in docker machine
- Why the “none” image appears in Docker and how can we avoid it
- How to pass ARG value to ENTRYPOINT?
- Log all queries in the official Postgres docker image
- Docker-Compose file has yaml.scanner.ScannerError
- MYSQL_ROOT_PASSWORD is set but getting “Access denied for user ‘root’@’localhost’ (using password: YES)” in docker container
- postgres with docker compose gives FATAL: role “root” does not exist error
- WordPress Docker won’t increase upload limit
- How to generate a Postgresql Dump from a Docker container?
- How are Packer and Docker different? Which one should I prefer when provisioning images?
- Difference between ‘image’ and ‘build’ within docker compose
- Can we mount sub-directories of a named volume in docker?
- Docker container for Postgres 9.1 not exposing port 5432 to host
- How to get into psql of a running postgres container?
- Operation of the mkdir command with dockerfile
- pq: could not resize shared memory segment. No space left on device
- Could not translate host name “db” to address using Postgres, Docker Compose and Psycopg2
- Using docker-compose to set containers timezones
- data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.0
- How to use a PostgreSQL container with existing data?
- Hidden file .env not copied using Docker COPY
- How to push Docker containers managed by Docker-compose to Heroku?
- Using Docker I get the error: “SQLSTATE[HY000]  No such file or directory”
- Rails server is still running in a new opened docker container
- Docker COPY not updating files when rebuilding container
- Docker-compose volume mount before run