I use docker compose on Jenkins to start our services and dependencies and run integration tests against them. It’s been working pretty well until that I need to run multiple instances of the services from the same docker compose file.
For example, my docker compose file has something like the following:
service-a:
image: xyz
container_name: service-a-${VERSION}
links:
- service_db
ports:
- “${SERVICE_A_PORT}:1234”
service_db:
image: abc
container_name: service_a_db-${VERSION}
ports:
- “${ SERVICE_A_DB_PORT }:5432”
The problem is that if two Jenkins jobs both run this file at the same time (with different environment variable values for the ports, version, etc), they still seem to interfere with each other because the keys (service-a, and service_db) are the same (I think in this case the problematic one is service_db because service-a links to it by the key).
Does anyone know if there is a way I can customize (pass in) the value of the key in a docker compose file?
Thanks!