docker-composeで下記の設定でpostgresサーバーを立ち上げようとした時に、下記のようなエラーが出ており原因は、ポート番号が既に使用されていると出ています。
使用状況を確認したところ停止はしていますが、使用されてるようでしたのでsudo kill -9 <pid>で削除したのですが、削除しても新しいpidが生成されてportが削除されなくて詰まってしまっています。
他に試したことは、dockerのimage/container/volume/networkを全て削除してみましたがダメでした。
解決方法わかるかたいましたらご教授いただけたら嬉しいです。
docker
1version: '3.7' 2services: 3 postgres: 4 image: postgres:12.2-alpine 5 container_name: postgres 6 ports: 7 - 5432:5432 8 volumes: 9 - ./docker/postgres/init.d:/docker-entrypoint-initdb.d 10 - ./docker/postgres/pgdata:/var/lib/postgresql/data 11 environment: 12 POSTGRES_USER: postgres 13 POSTGRES_PASSWORD: postgres 14 POSTGRES_INITDB_ARGS: '--encoding=UTF-8' 15 POSTGRES_DB: postgres 16 hostname: postgres 17 restart: always 18 user: root 19 20 pgadmin: 21 image: dpage/pgadmin4 22 restart: always 23 ports: 24 - 81:80 25 environment: 26 PGADMIN_DEFAULT_EMAIL: nestjs@example.com 27 PGADMIN_DEFAULT_PASSWORD: password 28 volumes: 29 - ./docker/pgadmin:/var/lib/pgadmin 30 depends_on: 31 - postgres
error
1$ docker-compose up -d 2 3Creating postgres ... error 4 5ERROR: for postgres Cannot start service postgres: Ports are not available: listen tcp 0.0.0.0:5432: bind: address already in use 6 7ERROR: for postgres Cannot start service postgres: Ports are not available: listen tcp 0.0.0.0:5432: bind: address already in use 8ERROR: Encountered errors while bringing up the project.
zash
1$ sudo lsof -i:5432 2 3COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME 4postgres 2097 postgres 4u IPv6 hoge 0t0 TCP *:postgresql (LISTEN) 5postgres 2097 postgres 5u IPv4 hoge 0t0 TCP *:postgresql (LISTEN)
zash
1$ ps aux | grep postgres 2postgres 2611 0.0 0.0 5018448 7448 ?? S 5:17PM 0:00.43 /usr/libexec/trustd --agent 3postgres 2120 0.0 0.0 4888424 1860 ?? Ss 4:29PM 0:00.00 postgres: logical replication launcher 4postgres 2119 0.0 0.0 4643468 1048 ?? Ss 4:29PM 0:00.10 postgres: stats collector 5postgres 2118 0.0 0.0 4945768 2200 ?? Ss 4:29PM 0:00.08 postgres: autovacuum launcher 6postgres 2117 0.0 0.0 4879208 5340 ?? Ss 4:29PM 0:00.05 postgres: walwriter 7postgres 2116 0.0 0.0 4748136 2372 ?? Ss 4:29PM 0:00.08 postgres: background writer 8postgres 2115 0.0 0.0 4756328 1240 ?? Ss 4:29PM 0:00.00 postgres: checkpointer 9postgres 2108 0.0 0.0 4602508 960 ?? Ss 4:29PM 0:00.00 postgres: logger 10postgres 2097 0.0 0.0 4749452 15680 ?? Ss 4:29PM 0:00.07 /Library/PostgreSQL/12/bin/postmaster -D/Library/PostgreSQL/12/data 11postgres 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 12postgres 1340 0.0 0.0 5158960 11716 ?? S 4:14PM 0:00.09 /usr/libexec/secd 13postgres 1338 0.0 0.0 5414788 8772 ?? S 4:14PM 0:00.08 /usr/libexec/lsd 14postgres 1336 0.0 0.0 5152348 7332 ?? S 4:14PM 0:00.05 /usr/libexec/pkd 15postgres 1335 0.0 0.0 4427440 1456 ?? S 4:14PM 0:00.02 /usr/sbin/cfprefsd agent 16postgres 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 17postgres 1302 0.0 0.0 4891772 3260 ?? S 4:13PM 0:00.05 /usr/sbin/distnoted agent 18nomin 3897 0.0 0.0 4418912 840 s002 S+ 6:44PM 0:00.00 grep postgres 19
回答1件
あなたの回答
tips
プレビュー