I'm trying to understand how to run multiple web applications on a Docker swarm that is running on VMWare hosts. And how to have external DNS resolve to the ip address of the container that is randomly allocated to run a single docker-compose application. Are labels and another solution the answer?
Here's the example setup:
- VMWare Host 1
- Docker Swarm Manager Primary (dsm-0)
- VMWare Host 2
- Docker Swarm Manager Replica (dsm-1)
- VMWare Host 3
- Docker Agent 1 (da-0)
- Docker Agent 2 (da-1)
- Docker Agent 3 (da-2)
- Docker Agent 4 (da-3)
I will have two overlay networks webapp-1-net, webapp-2-net. Then I will have a Docker image for a hypothetical webapp-1 and webapp-2. I will run these images on the docker swarm from the active swarm manager using the specific overlay network. Then they will be randomly allocated to one of the docker agents. Here is where my understanding gets shaky. I know that I can manually pull back whatever IP gets assigned to a docker agent and access the web application that way. However how do I make an external DNS/networking system that is on the level of the VMWare hosts, and how I make the hosts themselves, aware of the various applications running on the docker agents and route a subdomain like webapp1.example.com to the correct container or webapp2.example.com?