I'm using this method to deploy my docker-compose project to AWS ECS.

A simplified version of my docker-compose.yml looks like this:

version: '3'

    image: .dkr.ecr.eu-west-3.amazonaws.com/django:${IMAGE_TAG}
      context: .
      dockerfile: ./Dockerfile

    image: .dkr.ecr.eu-west-3.amazonaws.com/nginx:${IMAGE_TAG}
      context: .
      dockerfile: ./nginx.Dockerfile
      - 80:80
      - web

So, run docker compose up with my AWS ECS context and it works beautifully, cloud-formation creates all my resources and so on.

But, I can't figure out how to get these two services (web and nginx) to run in one task. Since they are in separate tasks at the moment it will create two instances of FARGATE or EC2 which is a bit overkill. I'd like two run the two containers on one instance but be able to scale up to more duplicate instances.

As stated in the link attached, I can modify the cloud-formation template to my liking, but something are limited to what I can modify. I don't think I can move that container service to another task since the image tag etc are created dynamically by docker compose.

My ECS cluster looks like this atm. enter image description here

1 Answer 1


What you are looking for is a sidecar pattern where you run a container of your main application and a number of additional containers (one or more) in support of it. This is a well established pattern with orchestrators such as ECS but it's not possible to declare it with a docker compose syntax today. There is an open request talking about this. Can I ask you to +1 it and add your commentary/request there? It would help Docker to sense demand for this feature. Thanks!

  • Will do, thank you! Commented Apr 30, 2021 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.