PostgreSQL via Docker Compose
Create Docker Compose file in location that you want to start it in
version: '3'
services:
postgres:
image: postgres:13.1
healthcheck:
test: [ "CMD", "pg_isready", "-q", "-d", "postgres", "-U", "root" ]
timeout: 45s
interval: 10s
retries: 10
restart: always
environment:
- POSTGRES_USER=<postgres_user>
- POSTGRES_PASSWORD=<postgres_user_pass>
- APP_DB_USER=<app_user>
- APP_DB_PASS=<app_user_pass>
- APP_DB_NAME=<app_database_name>
volumes:
- ./db:/docker-entrypoint-initdb.d/
ports:
- 5432:5432Create Database
INITScript
Should look like this:
Add the following script to is:
The script will:
create a new user and password assigned in the variables in the composed file
create the App database
grant the priviilages for the user on the database
connect to the database cand create a table called
event
Only thing left is to run the docker composed script:
This should now be reachable via DBeaver or pgAdmin

Last updated