用例上下文:我需要通过使用群组覆盖网络连接到服务的docker run
进行一些批处理。
我想使用docker stack deploy
推出网络和服务设置;
单个容器任务假脱机直接通过REST API完成。
因此,我想根据docker-compose.yml
版本3+文件表达以下shell命令。
$ docker network create \
--driver overlay \
--opt encrypted \
--internal \
--attachable \
--subnet 10.42.6.0/24 \
example_net
检查此网络可以很好地详细说明如何解释参数。
$ docker network inspect example_net
[{
"Name": "example_net",
"Id": "lw689m2su19p5imljtlfsfsxy",
"Created": "0001-01-01T00:00:00Z",
"Scope": "swarm",
"Driver": "overlay",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "10.42.6.0/24",
"Gateway": "10.42.6.1"
}
]
},
"Internal": true,
"Attachable": true,
"Containers": null,
"Options": {
"com.docker.network.driver.overlay.vxlanid_list": "4098",
"encrypted": ""
},
"Labels": null
}]
将这些检查结果翻译成我在docker-compose.yml
的第一次剪切:
version: "3.1"
networks:
example_net:
internal: true
driver_opts:
encrypted: ""
ipam:
config:
- subnet: 172.16.4.0/24
services:
db:
image: couchdb
networks:
- example_net
hostname: "{{.Service.Name}}-{{.Task.Slot}}-{{.Node.ID}}"
......到达结果配置结果:
$ docker stack deploy -c ./docker-compose.yml test
Creating network test_example_net
Creating service test_db
$ docker network inspect example_net
[{
"Name": "test_example_net",
"Id": "j1ahedyfh05mpg5g52vrd9034",
"Created": "2017-04-21T21:00:55.656972306Z",
"Scope": "swarm",
"Driver": "overlay",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.16.4.0/24",
"Gateway": "172.16.4.1"
}
]
},
"Internal": true,
"Attachable": false,
"Containers": { ... },
"Options": {
"com.docker.network.driver.overlay.vxlanid_list": "4100",
"encrypted": ""
},
"Labels": {"com.docker.stack.namespace": "test"},
"Peers": [ ... ]
}]
问题:有没有办法用"Attachable": true
命令设置docker stack deploy
?
答案 0 :(得分:3)
"attachable property not supported in docker-compose v3 format"有一个github问题。
这是#30742中添加的。它将在下一版本中以Compose file v3.2格式。
所以这应该是在Compose的1.12版本中,并且可能需要17 {+ 1}版本的Docker版本