環境
- wsl2
- ubunts 20.04
問題
以下のdocker-compose.yamlを記載してdockerを起動したが、pgAdmin4にログインできなかった。
docker-compose.yaml
version: '3.7'
services:
postgres:
image: postgres:14.2-alpine
container_name: postgres
ports:
- 5432:5432
volumes:
- ./docker/postgres/init.d:/docker-entrypoint-initdb.d
- ./docker/postgres/pgdata:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_INITDB_ARGS: "--encoding=UTF-8"
POSTGRES_DB: postgres
hostname: postgres
restart: always
user: root
pgadmin:
image: dpage/pgadmin4
restart: always
ports:
- 81:80
environment:
PGADMIN_DEFAULT_EMAIL: test@example.com
PGADMIN_DEFAULT_PASSWORD: password
volumes:
- ./docker/pgadmin:/var/lib/pgadmin
depends_on:
- postgres
解決策
pgadminのimageに4.2
のバージョンを指定してあげると起動できた。
最新の6.10では起動できない模様。
docker-compose.yaml
version: '3.7'
services:
postgres:
image: postgres:14.2-alpine
container_name: postgres
ports:
- 5432:5432
volumes:
- ./docker/postgres/init.d:/docker-entrypoint-initdb.d
- ./docker/postgres/pgdata:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_INITDB_ARGS: "--encoding=UTF-8"
POSTGRES_DB: postgres
hostname: postgres
restart: always
user: root
pgadmin:
image: dpage/pgadmin4:4.2 //追加
restart: always
ports:
- 81:80
environment:
PGADMIN_DEFAULT_EMAIL: test@example.com
PGADMIN_DEFAULT_PASSWORD: password
volumes:
- ./docker/pgadmin:/var/lib/pgadmin
depends_on:
- postgres