Docker Community Forums

Share and learn in the Docker community.

Same Application in a docker compose configuration mapping different ports on AWS EC2 instance

The app has the following containers

  • php-fpm
  • nginx
  • local mysql
  • app’s API
  • datadog container

In the dev process many feature branches are created to add new features. such as

  • app-feature1
  • app-feature2
  • app-feature3

I have an AWS EC2 instance per feature branches running docker engine V.18 and docker compose to build the and run the docker stack that compose the php app.

To save operation costs 1 AWS EC2 instance can have 3 feature branches at the same time. I was thinking that there should be a custom docker-compose with special port mapping and docker image tag for each feature branch.

The goal of this configuration is to be able to test 3 feature branches and access the app through different ports while saving money.

What recommendations do you give?

The solution to this is to give the docker-compose stack a project name and a network. There was lots of things involved. So a Python script allowed for the multi-execution of Bitbucket branches in different docker-compose stacks running on the same EC2 machine and getting different ports.