Skip to content

ch01-setupのpg18のDockerコンテナの起動に失敗 #1

Description

@Takehara-Biz

以下のymlファイルに対して、「docker compose up -d」を実行したのですが、pg18のコンテナの起動に失敗しました。
https://github.com/forest6511/postgresql-textbook-examples/blob/main/ch01-setup/docker-compose.yml

実行環境

  • MacBook Pro (Apple M1 Pro)
  • Docker Desktop 4.83.0

Dockerのlogは以下の通りです。

Error: in 18+, these Docker images are configured to store database data in a
format which is compatible with "pg_ctlcluster" (specifically, using
major-version-specific directory names). This better reflects how
PostgreSQL itself works, and how upgrades are to be performed.

See also docker-library/postgres#1259

Counter to that, there appears to be PostgreSQL data in:
/var/lib/postgresql/data (unused mount/volume)

This is usually the result of upgrading the Docker image without
upgrading the underlying database using "pg_upgrade" (which requires both
versions).

The suggested container configuration for 18+ is to place a single mount
at /var/lib/postgresql which will then place PostgreSQL data in a
subdirectory, allowing usage of "pg_upgrade --link" without mount point
boundary issues.

See docker-library/postgres#37 for a (long)
discussion around this process, and suggestions for how to do so.

以下の28行目の内容を、
https://github.com/forest6511/postgresql-textbook-examples/blob/main/ch01-setup/docker-compose.yml#L28

「pg18_data:/var/lib/postgresql/data」
から
「pg18_data:/var/lib/postgresql」
に書き換えると起動に成功します。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions