0
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[Docker Compose]postgres ✖️ pgadmin4

Posted at

本記事は、[Docker]postgres ✖️ pgadmin4Docker Composeで構成したものです。

環境

  • Docker: 4.25.2
  • postgres: 16.1
  • pgadmin4: 8.1

docker-compose.yaml

docker-compose.yaml
version: '3.9'

services:
  service_postgres:
    image: postgres:latest
    container_name: container_postgres
    environment: 
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    ports: 
      - "5432:5432"
    volumes:
      - volume_postgres:/var/lib/postgresql/data
  
  service_pgadmin:
    image: dpage/pgadmin4:latest
    container_name: container_pgadmin
    ports:
      - 8080:80
    volumes:
      - volume_pgadmin:/var/lib/pgadmin
    environment:
      PGADMIN_DEFAULT_EMAIL: example@domain.com
      PGADMIN_DEFAULT_PASSWORD: password
    depends_on:
      - service_postgres

volumes:
  volume_postgres:
  volume_pgadmin:

コンテナの起動

公式のイメージはbuild済みのため、docker compose buildコマンドは不要。

$ docker compose up

接続情報の設定

  • ホスト名/アドレスはコンテナ名を入力。

デフォルトで Compose はアプリに対して1つの ネットワーク を作成します。サービス用の各コンテナはデフォルトのネットワークに接続し、そのネットワーク上で他のコンテナと相互に「 接続可能reachable 」になります。そして、コンテナ名と同じホスト名として、お互いが「 発見可能discoverable 」になります。

参考:Compose の ネットワーク機能

スクリーンショット 2024-01-11 10.12.10.png

0
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?