Also you are giving the stack the option to join that main network but your not adding the service to that network…
Example
networks:
main:
name: main
external: true
services:
plex:
networks:
main:
ipv4_address: 172.24.5.1
tautulli:
networks:
- main
third-app-instack:
This part:
networks:
main:
name: main
external: true
Application in this stack MAY join the main network (not are joining, MAY)
then
services:
plex-hades:
networks:
main:
ipv4_address: 172.24.5.1
tautulli-hades:
networks:
- main
third-app-instack:
Three apps here…
- Plex joins main and gets a manualy IP 172.24.5.1
- tautulli joins main and gets a dynamic IP
- The third app at the bottom will make its won network because we didnt tell it what to do… if we wanted third app to join main with dynamic then:
services:
plex-hades:
networks:
main:
ipv4_address: 172.24.5.1
tautulli-hades:
networks:
- main
third-app-instack:
networks:
- main
Now all would be on the same… also the internal IP does not matter if you publish your port using ports: then it just takes a port on the host.
Just remember external networks (pre-created) must have the stack reference it AND the app must join it.
Docker is done this way so a stack can join multiple networks…
More complex example (all three would need to already exist created form command line)
networks:
frontend:
name: frontend
external: true
backend:
name: backend
external: true
proxy:
name: proxy
external: true
With this loaded into a stack the apps could join 1, 2, or 3 of these and also make their own networks
Then we add apps to that with
networks:
frontend:
name: frontend
external: true
backend:
name: backend
external: true
proxy:
name: proxy
external: true
services:
APP1:
networks:
- frontend
APP2:
networks:
- backend
APP3:
networks:
- main
- frontend
- proxy
APP4:
networks:
- proxy
- frontend
APP5:
Notice APP 5 makes it own network as it did NOT join any of the pre-created