doc.dev1x.org

PostgreSQLのDockerコンテナを立ち上げる

概要

ディレクトリ構造

.
├── data/
└── docker-compose.yaml

コンテナ作成

docker-compose.yaml

version: '3.7'
services:
  postgres:
    image: postgres:13
    container_name: postgres
    environment:
      POSTGRES_USER: pgadmin
      POSTGRES_PASSWORD: password
      POSTGRES_DB: pg_db
    volumes:
      - ./data:/var/lib/postgresql/data
    ports:
      - 5432:5432

コンテナ起動

docker-compose up -d
docker-compose ps


  Name                Command              State                    Ports
-------------------------------------------------------------------------------------------
postgres   docker-entrypoint.sh postgres   Up      0.0.0.0:5432->5432/tcp,:::5432->5432/tcp