I don't blog these days - havent done so for many years, but I'll just make a note of something here that I learnt through experimentation (docs are lacking IMO) about docker swarm networking:
If you deploy a docker image to a cluster and don't specify a host port, just a container port, then when another container attempts to connect to it, it will be able to do so using the *container* port, and not have to concern itself with the random *host* port that docker swarm assigns the container.
This is A BIG DEAL in my opinion - it means you can create 10s, 100s of replicas of some image on a docker cluster and have your other services (also running on the cluster through docker swarm) connect to them, load balanced, by just resolving them by their service name (e.g my-service) and connect to their known container port - most likely port 80, if it's a microservice with an HTTP API.
This may be obvious to more experienced docker swarm users, but for me I was unable to learn this from the documentation, but ended up discovering it through experimentation after being frustrated about how to deploy many replicas of a service and be able to load balance between them.
Anyway...no-one will ever read this but me so...g'bye me.
Comments