Postgre In Docker

guides/postgres/postgres.png

Docker Compose

 1version: '3.2'
 2
 3services:
 4  postgres:
 5    container_name: postgres_pi
 6    image: postgres
 7    ports:
 8      - 5432:5432
 9    volumes:
10      - ./:/var/lib/postgresql
11    env_file:
12      - .env
13    restart: always

Create a .env file in the same folder as the docker-compose.yml

.env

POSTGRES_PASSWORD=password
POSTGRES_USER=username
POSTGRES_DB=db_name

Deploy

1sudo docker-compose up -d