Search code examples
dockerroutesdocker-composemicroservicesdocker-swarm

Docker swarm mode, internally running several services with unique domain names but each on port 80


I'm trying to setup a microservice deployment (deployment file at https://github.com/mojlighetsministeriet/groups/blob/master/docker-compose.example.yml) with several services that will use HTTP (hopefully HTTPS later on) to communicate internally without being exposed outside the network. I later on will add a proxy service that will expose specific features. I want to do this specifically with docker swarm mode and I like the possibility to define the deployment in a docker-compose.yml so I can initiate with:

$ docker stack deploy my-platform -c docker-compose.example.yml

I want the API urls internally to be like GET http://identity-provider/public-key and GET http://groups/b0c44674-58e0-4a8a-87e0-e1de35088964 . I have done this with Kubernetes setups before and that works great but now I want to get this working with docker swarm mode.

The DNS parts works without any problems, but docker swarm mode won't allow me to have each service listening on port 80 (will later be 443). It keeps complaining about port conflicts even though each service has it's unique domain name like identity-provider or groups and so on.

Should I use a specific network driver to get this working? I currently use overlay.

Using domain names without random ports would make calling in between the services much more simple to remember than e.g. http://identity-provider:1234 and http://groups:1235, the ports only adds complexity to the setup.

I'm fine with using any super cutting edge version of docker-ce if that helps somehow.

This should be possible right?


Solution

  • Docker Swarm routes incoming requests based on the published port, you can't have two applications with the same port number in a single Swarm.