Use-case context: I need to do some batch processesing via docker run
that connects to services using the swarm overlay network.
I want to use docker stack deploy
to roll out the networking and service setups;
the individual container task spooling is done directly through the REST API.
Thus, I'd like to express the following shell command in terms of a docker-compose.yml
version 3+ file.
$ docker network create \
--driver overlay \
--opt encrypted \
--internal \
--attachable \
--subnet 10.42.6.0/24 \
example_net
Inspecting this network gives good detail of how the arguments are interpreted.
$ 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
}]
Translating those inspection results into my first cut at the 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}}"
…arriving at a close configuration result:
$ 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": [ ... ]
}]
Question: Is there a way to set "Attachable": true
with the docker stack deploy
command?
There's a github issue for "attachable property not supported in docker-compose v3 format".
This was added in #30742. It will be in Compose file v3.2 format in the next release.
So that should be in the 1.12 release of Compose and probably needs a 17+ release of Docker for docker stack