본문 바로가기
DataBase

PostgreSQL 13 설치 with docker-compose

by 맑은안개 2023. 2. 5.

들어가며

docker-compose를 사용하여 간단하게 PostgreSQL 13버전을 설치하고 DBeaver를 사용, 접속하는 방법도 알아봅니다.

docker-compose.yml

version: '3'
services:
  db:
    image: postgres:13-alpine
    environment:
      POSTGRES_USER: app
      POSTGRES_PASSWORD: app1234
      POSTGRES_DB: appdb
    ports:
      - "5432:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data
volumes:
  pgdata:
  • postgres:13-alpine은 linux기반 경량 postgres 이미지입니다.

docker-compose 실행

docker-compose up

<중략>
b_1  | 2023-02-04 11:10:43.146 UTC [1] LOG:  starting PostgreSQL 13.9 on aarch64-unknown-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924, 64-bit
db_1  | 2023-02-04 11:10:43.146 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
db_1  | 2023-02-04 11:10:43.146 UTC [1] LOG:  listening on IPv6 address "::", port 5432
db_1  | 2023-02-04 11:10:43.148 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1  | 2023-02-04 11:10:43.152 UTC [52] LOG:  database system was shut down at 2023-02-04 11:10:43 UTC
db_1  | 2023-02-04 11:10:43.155 UTC [1] LOG:  database system is ready to accept connections
  • 위와 같이 5432포트로 실행된을 확인합니다.
  • 백그라운드 실행은 -d 옵션을 뒤에 붙입니다.

  • docker-compose에 USER/PASSWORD/DB에 입력한 정보를 넣고 정상 접속을 확인합니다.
반응형