docker-composeで下記の設定でpostgresサーバーを立ち上げようとした時に、下記のようなエラーが出ており原因は、ポート番号が既に使用されていると出ています。
使用状況を確認したところ停止はしていますが、使用されてるようでしたのでsudo kill -9 <pid>で削除したのですが、削除しても新しいpidが生成されてportが削除されなくて詰まってしまっています。
他に試したことは、dockerのimage/container/volume/networkを全て削除してみましたがダメでした。
解決方法わかるかたいましたらご教授いただけたら嬉しいです。
docker
version: '3.7' services: postgres: image: postgres:12.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: nestjs@example.com PGADMIN_DEFAULT_PASSWORD: password volumes: - ./docker/pgadmin:/var/lib/pgadmin depends_on: - postgres
error
$ docker-compose up -d Creating postgres ... error ERROR: for postgres Cannot start service postgres: Ports are not available: listen tcp 0.0.0.0:5432: bind: address already in use ERROR: for postgres Cannot start service postgres: Ports are not available: listen tcp 0.0.0.0:5432: bind: address already in use ERROR: Encountered errors while bringing up the project.
zash
$ sudo lsof -i:5432 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME postgres 2097 postgres 4u IPv6 hoge 0t0 TCP *:postgresql (LISTEN) postgres 2097 postgres 5u IPv4 hoge 0t0 TCP *:postgresql (LISTEN)
zash
$ ps aux | grep postgres postgres 2611 0.0 0.0 5018448 7448 ?? S 5:17PM 0:00.43 /usr/libexec/trustd --agent postgres 2120 0.0 0.0 4888424 1860 ?? Ss 4:29PM 0:00.00 postgres: logical replication launcher postgres 2119 0.0 0.0 4643468 1048 ?? Ss 4:29PM 0:00.10 postgres: stats collector postgres 2118 0.0 0.0 4945768 2200 ?? Ss 4:29PM 0:00.08 postgres: autovacuum launcher postgres 2117 0.0 0.0 4879208 5340 ?? Ss 4:29PM 0:00.05 postgres: walwriter postgres 2116 0.0 0.0 4748136 2372 ?? Ss 4:29PM 0:00.08 postgres: background writer postgres 2115 0.0 0.0 4756328 1240 ?? Ss 4:29PM 0:00.00 postgres: checkpointer postgres 2108 0.0 0.0 4602508 960 ?? Ss 4:29PM 0:00.00 postgres: logger postgres 2097 0.0 0.0 4749452 15680 ?? Ss 4:29PM 0:00.07 /Library/PostgreSQL/12/bin/postmaster -D/Library/PostgreSQL/12/data postgres 1344 0.0 0.0 5270900 6292 ?? S 4:14PM 0:00.05 /usr/libexec/containermanagerd --runmode=agent --bundle-container-mode=global --bundle-container-owner=_appinstalld --system-container-mode=none postgres 1340 0.0 0.0 5158960 11716 ?? S 4:14PM 0:00.09 /usr/libexec/secd postgres 1338 0.0 0.0 5414788 8772 ?? S 4:14PM 0:00.08 /usr/libexec/lsd postgres 1336 0.0 0.0 5152348 7332 ?? S 4:14PM 0:00.05 /usr/libexec/pkd postgres 1335 0.0 0.0 4427440 1456 ?? S 4:14PM 0:00.02 /usr/sbin/cfprefsd agent postgres 1334 0.0 0.0 6079736 9204 ?? SN 4:14PM 0:02.35 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mdbulkimport -s mdworker-bundle -c MDSImporterBundleFinder -m com.apple.metadata.mdbulkimport postgres 1302 0.0 0.0 4891772 3260 ?? S 4:13PM 0:00.05 /usr/sbin/distnoted agent nomin 3897 0.0 0.0 4418912 840 s002 S+ 6:44PM 0:00.00 grep postgres
まだ回答がついていません
会員登録して回答してみよう