Not sure if there is a feature for this, hence my question:
I use Docker Compose to build a dev environment. I work with big data tools that need to scale, like Zookeeper, Kafka, stream processing engine etc…
Compose is great to spin a cluster quickly and run it on one machine; links allow to link containers so they can talk to each other, but outside the container, it’s opaque.
Of courseI I can expose the ports to the outside, but I can’t ‘fix’ a port on a scalable container: it is assigned automatically.
That becomes a pain when running with external tools: either I bind a random port to one IP and I need to figure out ALL the ports assigned every time I rebuild the environment. Or i can assign an IP and port, but then I can’t auto-scale anymore.
Ideally I’d like to ‘scale’ container with a naming scheme I define, so that external IP is assigned automatically and all I need is know the name. For example if I have 3 Zookeeper nodes, and the scheme is zk#, then I know they can be reached at their standard port on zk1, zk2 and zk3 for example… generating etc/hosts file and such
That makes life a lot easier.
Is there a way to do such a thing easily? Or does it just need to be scripted?
I can script the generation of the docker-compose.yml to do that, but that kinda defeats the purpose of the ‘scale’ function.
I apreciate your thougths on this.
Thanks