我docker-compose.yml
定義postgres
服務器:無法連接到Postgres的容器
db:
image: postgres:9.5
expose:
- 5432
然後在另一個泊塢窗容器我試圖連接到這個Postgres的容器。但是它給出了警告的錯誤:
Is the server running on host "db" (172.22.0.2) and accepting
data-service_1 | TCP/IP connections on port 5432?
爲什麼容器無法提供的資料(host
=「DB」,並port
= 5432
)連接到另一臺?
PS 全部docker-compose.yml
:
version: "2"
services:
data-service:
build: .
depends_on:
- db
ports:
- "50051:50051"
db:
image: postgres:9.5
depends_on:
- data-volume
environment:
- POSTGRES_USER=cobrain
- POSTGRES_PASSWORD=a
- POSTGRES_DB=datasets
ports:
- "8000:5432"
expose:
- 5432
volumes_from:
- data-volume
# - container:postgres9.5-data
restart: always
data-volume:
image: busybox
command: echo "I'm data container"
volumes:
- /var/lib/postgresql/data
請張貼滿'泊塢窗,compose.yml' –
@AlexKarshin我加入吧。 –