I am running Docker Compose (v2) and have a node service (website) and python based api deployed with nginx sitting in front of them.
One thing I would like to do is scale the services by adding more containers. If I know in advance how many containers I will have, I can tightly configure the nginx upstream config with links to the IP addresses of the containers that the docker provides. However, the problem is that I want the nginx upstream configuration to be dynamic, for example. if I add another Docker container, it will simply add the location of the container to the upstream list of IP addresses in the top block.
My idea was to create a script that would automatically add upstream servers using env variables when the containers change, but I'm not sure where to start, and can't find a good example.
source share