Sign inSign up

hcrit/postgres

By hcrit

•Updated almost 2 years ago

PostgreSQL database image

Image
0

1.3K

hcrit/postgres repository overview

⁠hcrit/postgres

The hcrit/postgres image provides a Docker container with installed PostgreSQL database. It is based on the official postgres⁠ image.

Besides Postgres, container provides:

  • created database superuser
  • created user with CREATEDB privileges (optional)
  • locale set to hr_HR.utf8

⁠Supported tags

Tags describe the version of PostgreSQL database used in the image.

  • 12, latest
  • 11.2
  • 10.4
  • 8.4

⁠Run container

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

⁠Environment variables

With environment variables you can set:

  • name of created database (POSTGRES_DB) - default: postgres
  • superuser name (POSTGRES_USER) - default: postgres
  • additional user (DB_USER) with password (DB_PASSWORD)

All 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.

⁠Access running container from docker host

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

⁠Access running container from client

Run psql from a client:

$ psql -h docker_host -p 25432 -U postgres -d my_db

Tag summary

Content type

Image

Digest

sha256:4ac28da9c…

Size

145.9 MB

Last updated

almost 2 years ago

docker pull hcrit/postgres