Even if aliases are specified in the configuration file, docker stack deploy seems to ignore them, while docker-compose up honors the same configuration.
Please see info.txt for docker info output and version.txt for docker version output; see also bugrep.txt that will be referred in the following as bugrep.yml used below.
docker-compose (alias works):First create a network with docker network create anexternalnet then run docker-compose -f bugrep.yml up -d, inspect the only created container, obtaining compose.txt output. As you can see, the Networks part shows the defined alias.
"Networks": {
"anexternalnet": {
"Aliases": [
"aservice",
"analias",
"9a1ffe79138b"
],
...
docker stack deploy (alias seems not to work):Cleanup the previously created containers and netowrk, and start swarm mode with docker swarm init.
Then create a network in the swarm scope with docker network create --scope swarm anexternalnet and then run docker stack deploy -c bugrep.yml bugrep, inspect the only created container, obtaining stack.txt. As you will see, the Networks part now is
"Networks": {
"anexternalnet": {
"Aliases": [
"fc19e2612ffb",
],
...
the alias analias(and the service name aservice) are both missing.
I can't reproduce this with engine v17.12, and cli master.
version: '3.5'
services:
foo:
image: redis:alpine
networks:
innet: {aliases: [analias]}
extswarmnet: {aliases: [analias]}
overextswarmnet: {aliases: [analias]}
networks:
extswarmnet:
external:
name: extswarmnet
overextswarmnet:
external:
name: overextswarmnet
innet:
"Networks": [
{
"Target": "wwxmmfzfwk4csf0sfitkui0if",
"Aliases": [
"analias",
"foo"
]
},
{
"Target": "i680iavd5etjqidijhe46yvrk",
"Aliases": [
"analias",
"foo"
]
},
{
"Target": "uhnmbr69v1rnlpgi39m6g5dxj",
"Aliases": [
"analias",
"foo"
]
}
],
$ docker network ls | grep ext
wwxmmfzfwk4c extswarmnet bridge swarm
i680iavd5etj overextswarmnet overlay swarm
Switching to edge 17.11.0-ceon OSX seems to fix it too (albeit I had to set version: '3'.
I'm having the same issue: aliases only work on external networks with docker-compose. With docker stack deploy, no alias is applied. Any changes on this behavior lately?
Client: Docker Engine - Community
Version: 19.03.4
API version: 1.40
Go version: go1.12.10
Git commit: 9013bf583a
Built: Fri Oct 18 15:54:09 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.4
API version: 1.40 (minimum version 1.12)
Go version: go1.12.10
Git commit: 9013bf583a
Built: Fri Oct 18 15:52:40 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.10
GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339
runc:
Version: 1.0.0-rc8+dev
GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
docker-init:
Version: 0.18.0
GitCommit: fec3683
Excuse the necro, but this still isn't working, and I never saw an actual solution/answer :confused:
docker-compose.yml contains:
version: "3"
services:
bot:
image: "mapper"
command: "./snart -dburl mapper-db -dbpass REDACTED"
depends_on:
- "db"
networks:
traefik:
db:
image: "recli"
volumes:
- "/var/db/mapper:/data:rw"
networks:
traefik:
aliases:
- "mapper-db"
networks:
traefik:
external: true
docker container inspect on the db container shows:
"Networks": {
"traefik": {
"IPAMConfig": {},
"Links": null,
"Aliases": [
"2b54a9e39d44"
],
"NetworkID": "wots16xw8q6jlh4j4f6vpgww4",
"EndpointID": "7cf9cd3963609b571dd32e76fbb4bdf9bdc4c865aaed2bf04641fa855fc5dea2",
"Gateway": "192.168.208.1",
"IPAddress": "192.168.208.6",
"IPPrefixLen": 20,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:c0:a8:d0:06",
"DriverOpts": null
}
}
docker version shows:
Client:
Version: 19.03.8-ce
API version: 1.40
Go version: go1.14.1
Git commit: afacb8b7f0
Built: Thu Apr 2 00:04:36 2020
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 19.03.8-ce
API version: 1.40 (minimum version 1.12)
Go version: go1.14.1
Git commit: afacb8b7f0
Built: Thu Apr 2 00:04:16 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.3.3.m
GitCommit: d76c121f76a5fc8a462dc64594aea72fe18e1178.m
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
Most helpful comment
Excuse the necro, but this still isn't working, and I never saw an actual solution/answer :confused:
docker-compose.ymlcontains:docker container inspecton thedbcontainer shows:docker versionshows: