christianlempa-boilerplates/docker-compose/postgres/docker-compose.yaml
Christoph Schug 911fcc61eb feat: interpolate name of user and database
Unless explicitely set, the database name is nevertheless derived from
the user by the image's entrypoint, but we can make this more obvious by
defining a interpolation here.
2024-03-06 21:33:39 +01:00

41 lines
1.0 KiB
YAML

---
version: "3.8"
services:
postgres:
image: docker.io/library/postgres:16.2
environment:
- POSTGRES_INITDB_ARGS=${POSTGRES_INITDB_ARGS---data-checksums}
- POSTGRES_HOST_AUTH_METHOD=${POSTGRES_HOST_AUTH_METHOD-}
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password
- POSTGRES_DB=${POSTGRES_DB:-$POSTGRES_USER}
- TZ=${TZ:-UTC}
ports:
- 5432:5432
# (Optional) when using custom network, see also
# https://docs.docker.com/compose/compose-file/compose-file-v3/#networks
#
# networks:
# - yournetwork
secrets:
- postgres_password
volumes:
- postgres_data:/var/lib/postgresql/data
restart: unless-stopped
# (Optional) when using custom network, see also
# https://docs.docker.com/compose/compose-file/compose-file-v3/#network-configuration-reference
#
# networks:
# yournetwork:
# external: true
secrets:
postgres_password:
file: secret.postgres_password.txt
volumes:
postgres_data:
driver: local