Is it possible to create services in a loop with docker-compose rather than typing all the services by hand? (See example below of creating 100 workers with appropriate ports)
version: '3'
services:
redis:
image: redis
worker1:
build: .
ports:
- "5001:5001"
worker2:
build: .
ports:
- "5002:5002"
worker3:
build: .
ports:
- "5003:5003"
...
worker100:
build: .
ports:
- "5100:5100"
You can probably do it with the --scale
option, so if you run docker-compose up --scale worker=100
it should do exactly what you want.
The documentation for docker-compose up references this as follows:
--scale SERVICE=NUM Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With