I am using an application which run on 3 different dockers:
It sounds like you just want 3 different environments or "stacks" of your Compose application running independently of each other. If this is the case, you can handle this with the --project-name
or -p
option to docker-compose
. An example would be something like this:
docker-compose -p appv1 up -d
docker-compose -p appv2 up -d
docker-compose -p appv3 up -d
At this point, you would have 3 different sets of containers running that can scale independently of each other. Docker Compose will prepend the project name (which is usually inferred from the folder name) to the container names. You will end up with container names such as appv1_worker_1
, appv2_worker_1
, appv3_worker1
. If you were to scale only appv2
worker service (docker-compose -p appv2 scale worker=2
) you would then get an additional appv2_worker_2
.
By default, compose always creates a default network that the containers can talk inside of. In this case, you would have 3 independent networks (appv1_default
, appv2_default
, and appv3_default
).
If you next wanted to run different images for each project name, you could use environment variable interpolation in the docker-compose.yml
. For example, you could specify image: ${MYIMAGE}
for a service and then do something such as:
MYIMAGE=myorg/myapp:v1 docker-compose -p appv1 up -d
MYIMAGE=myorg/myapp:v2 docker-compose -p appv2 up -d
Hope this is helpful as an idea to do it inside of Docker Compose.