Last active
May 15, 2020 13:43
-
-
Save saponace/71be440919d302f44f9d52c9a875f83f to your computer and use it in GitHub Desktop.
Docker compose service with "network_mode: service: [...]" does not inherit parent's service networks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.8" | |
networks: | |
web: | |
name: web | |
services: | |
whoami: | |
container_name: whoami | |
image: containous/whoami:v1.5.0 | |
network_mode: service:net_holder | |
labels: | |
- traefik.enable=true | |
- traefik.docker.network=web | |
- traefik.http.routers.whomai.rule=Host(`whoami.EXAMPLE.TLD`) | |
- traefik.http.services.whoami.loadbalancer.server.port=80 | |
whoami2: | |
container_name: whoami2 | |
image: containous/whoami:v1.5.0 | |
networks: | |
- web | |
labels: | |
- traefik.enable=true | |
- traefik.docker.network=web | |
- traefik.http.routers.whomai2.rule=Host(`whoami2.EXAMPLE.TLD`) | |
- traefik.http.services.whoami2.loadbalancer.server.port=80 | |
net_holder: | |
container_name: net_holder | |
image: containous/whoami:v1.5.0 | |
command: | |
- --port=9999 # We don't cara about the exposed port. This container just acts as a network holder | |
# cap_add: | |
# - NET_ADMIN | |
# devices: | |
# - /dev/net/tun | |
networks: | |
- web | |
traefik: | |
container_name: traefik | |
image: traefik:2.2.1 | |
restart: unless-stopped | |
command: | |
- --api.dashboard=true | |
- --log.level=INFO | |
- --providers.docker=true | |
- --providers.docker.network=web | |
- --entryPoints.web.address=:80 | |
networks: | |
- web | |
ports: | |
- 80:80 | |
- 443:443 | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock:ro | |
labels: | |
- traefik.enable=true | |
- traefik.docker.network=web | |
- traefik.http.routers.traefik.rule=Host(`traefik.EXAMPLE.TLD`) | |
- traefik.http.routers.traefik.service=api@internal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.8" | |
networks: | |
web: | |
name: web | |
services: | |
whoami: | |
container_name: whoami | |
image: containous/whoami:v1.5.0 | |
network_mode: service:net_holder | |
whoami2: | |
container_name: whoami2 | |
image: containous/whoami:v1.5.0 | |
networks: | |
- web | |
net_holder: | |
container_name: net_holder | |
image: containous/whoami:v1.5.0 | |
command: | |
- --port=9999 # We don't cara about the exposed port. This container just acts as a network holder | |
# cap_add: | |
# - NET_ADMIN | |
# devices: | |
# - /dev/net/tun | |
networks: | |
- web |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment