Run multiple docker compose

Viewed 37439

I am using an application which runs on 3 different docker images:

  • The first one is the server HTTP callable with a REST API
  • The second one is rabbitmq
  • The third one is a worker

The whole application is launched with docker-compose up

Really simple :)

I would like to make it scalable and run multiple instances of this entire application (the 3 docker images) independently of the others, and then put a load balancer like haproxy which will redirect to one of the applications.

I saw that I can use docker-compose up --scale blablabla however the problem with this is that I can scale containers, but I really want to keep the different "applications" independent.

For example if I want 3 versions of the app I will have 9 docker images etc.

I saw that we can run docker inside docker with --privilege (allowing me to create one docker with the 3 dockers inside) but I read on Stack Overflow that it is not a suitable solution.

Do you have a solution? Or at least some documents to read.

I heard that Kubernetes could be a solution but I am not sure. I read (on Stack):

If you need multiple containers tightly bound, you may want to look at Kubernetes that runs docker inside their "pods"

3 Answers

If you want to run multiple docker-compose files at once from a single command, use this method. If the compose files are docker-compose1.yml and docker-compose2.yml, you can run both docker files using,

docker-compose -f docker-compose1.yml -f docker-compose2.yml up

You can use a .env file. There you must set a COMPOSE_FILE environment variable and set it to COMPOSE_FILE=a.yaml:b.yaml:c.yaml

Now you can run all compose files with docker-compose up

projekt/
    .env
    a.yaml
    b.yaml
    c.yaml
Related