The hcrit/postgres image provides a Docker container with installed PostgreSQL database. It is based on the official postgres image.
Besides Postgres, container provides:
Tags describe the version of PostgreSQL database used in the image.
To run a container named postgres:
$ docker run -d \
--name postgres \
-e POSTGRES_PASSWORD=password \
hcrit/postgres:latest
To run a container using different port and persistent location for the database:
$ docker run -d \
--name postgres \
-p 25432:5432 \
-v /persistent_dir:/var/lib/postgresql/data \
-e POSTGRES_PASSWORD=password \
hcrit/postgres:latest
With environment variables you can set:
postgrespostgresAll environment variables can be set in a file (e.g. postgres.env):
POSTGRES_DB=my_db
POSTGRES_PASSWORD=postgres_password
DB_USER=my_user
DB_PASSWORD=my_user_password
To run container with environemnt file postgres.env:
$ docker run -d \
--name postgres \
-p 25432:5432 \
-v /persistent_dir:/var/lib/postgresql/data \
--env-file=postgres.env \
hcrit/postgres:latest
For other environment variables that you can set check documentation of the official postgres image.
To gain shell access to running container postgres:
$ docker exec -it postgres bash
To run psql in the container:
$ docker exec -it postgres psql -U postgres -d my_db
Run psql from a client:
$ psql -h docker_host -p 25432 -U postgres -d my_db
Content type
Image
Digest
sha256:4ac28da9c…
Size
145.9 MB
Last updated
almost 2 years ago
docker pull hcrit/postgres