以下是我的docker-compose文件。我不确定我缺少什么。但是我无法从本地主机
连接到postgres dev_db:
image: postgres
volumes:
- ./db_data/postgres:/var/lib/postgresql/data
expose:
- "5432"
ports:
- "5433:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"```
psql cmd fom loclhost
``` sitharamk$ psql -h localhost -p 5433 -U postgres -W
Password:
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5433?```
答案 0 :(得分:0)
代替
expose:
- "5432"
ports:
- "5433:5432"
您只需要
ports:
- "5433:5432"