我在运行大约10种不同服务的测试服务器中使用Docker Swarm。我使用docker compose创建服务,然后连接到预先存在的网桥网络,而不是默认的覆盖网络:
h2r@test-server:~$ docker network inspect ecommerce-new-bridge
[{
"Name": "ecommerce-new-bridge",
"Id": "pwty628ng11z2px8rz39bdsfx",
"Created": "2019-01-10T10:46:14.14717554Z",
"Scope": "swarm",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "",
"Options": null,
"Config": []
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": null,
"Options": null,
"Labels": null
}]
这是我的docker compose之一:
version: '3.5'
services:
zookeeper:
image: wurstmeister/zookeeper:3.4.6
deploy:
resources:
limits:
memory: 128M
reservations:
memory: 32M
ports:
- 2181:2181
environment:
- _JAVA_OPTIONS=-Xmx128m -Xms32m
kafka:
image: wurstmeister/kafka:1.0.0
depends_on:
- zookeeper
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 128M
environment:
KAFKA_ADVERTISED_HOST_NAME: 192.168.1.100
KAFKA_ZOOKEEPER_CONNECT: 192.168.1.100:2181
KAFKA_HEAP_OPTS: -Xmx256M -Xms128M
ports:
- 9092:9092
postgresql:
image: postgres:10.6
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 128M
volumes:
- /opt/volumes/postgresql:/var/lib/postgresql/data
environment:
- POSTGRES_USER=teste
- POSTGRES_PASSWORD=teste
- POSTGRES_DB=postgres
ports:
- 5432:5432
networks:
default:
external: true
name: ecommerce-new-bridge
当我第一次创建网络并部署服务时,它就像一个魅力。但是有时我们需要重新启动这台计算机,而不仅仅是启动服务,docker还在抱怨网络:
Rejected 8 seconds ago "network pwty628ng11z2px8rz39bdsfx exists"
roh4aroxisobwwqcc144vp9bq ecommerce_zookeeper.1 wurstmeister/zookeeper:3.4.6@sha256:294d69bb580a614ed3128969b95b5355c480e84704d826cdf73e790b5a6e63fc test-server Shutdown
当然,该网络存在,但已在撰写文件中将其标记出来。 我在做错什么吗?