如何在 docker 堆栈部署上禁用网络生成
How to disable network generation on docker stack deploy
我正在通过以下方式将撰写文件部署到 UCP:
docker stack deploy -c docker-compose.yml custom-stack-name
最后我想将多个撰写文件(每个撰写文件描述一个单独的微服务的设置)部署到一个 docker 网络上,例如应用网络
version: "3"
services:
service1:
image: docker/service1
networks:
- appsnetwork
customservice2:
image: myprivaterepo/imageforcustomservice2
networks:
- appsnetwork
networks:
appsnetwork:
docker stack deploy
命令会自动创建一个新网络,其生成的名称如下:custom-stack-name_appsnetwork
我有哪些选择?
首先尝试自己创建网络
docker network create --driver=overlay --scope=swarm appsnetwork
然后在你的 compose 中建立外部网络
version: "3"
services:
service1:
image: nginx
networks:
- appsnetwork
networks:
appsnetwork:
external: true
之后运行两份堆栈
docker stack deploy --compose-file docker-compose.yml stack1
docker stack deploy --compose-file docker-compose.yml stack2
Docker 检查同一网络中的两个显示 IP
$ docker inspect 369b610110a9
...
"Networks": {
"appsnetwork": {
"IPAMConfig": {
"IPv4Address": "10.0.1.5"
},
"Links": null,
"Aliases": [
"369b610110a9"
],
$ docker inspect e8b8cc1a81ed
"Networks": {
"appsnetwork": {
"IPAMConfig": {
"IPv4Address": "10.0.1.3"
},
"Links": null,
"Aliases": [
"e8b8cc1a81ed"
],
我正在通过以下方式将撰写文件部署到 UCP:
docker stack deploy -c docker-compose.yml custom-stack-name
最后我想将多个撰写文件(每个撰写文件描述一个单独的微服务的设置)部署到一个 docker 网络上,例如应用网络
version: "3"
services:
service1:
image: docker/service1
networks:
- appsnetwork
customservice2:
image: myprivaterepo/imageforcustomservice2
networks:
- appsnetwork
networks:
appsnetwork:
docker stack deploy
命令会自动创建一个新网络,其生成的名称如下:custom-stack-name_appsnetwork
我有哪些选择?
首先尝试自己创建网络
docker network create --driver=overlay --scope=swarm appsnetwork
然后在你的 compose 中建立外部网络
version: "3"
services:
service1:
image: nginx
networks:
- appsnetwork
networks:
appsnetwork:
external: true
之后运行两份堆栈
docker stack deploy --compose-file docker-compose.yml stack1
docker stack deploy --compose-file docker-compose.yml stack2
Docker 检查同一网络中的两个显示 IP
$ docker inspect 369b610110a9
...
"Networks": {
"appsnetwork": {
"IPAMConfig": {
"IPv4Address": "10.0.1.5"
},
"Links": null,
"Aliases": [
"369b610110a9"
],
$ docker inspect e8b8cc1a81ed
"Networks": {
"appsnetwork": {
"IPAMConfig": {
"IPv4Address": "10.0.1.3"
},
"Links": null,
"Aliases": [
"e8b8cc1a81ed"
],