Le_Coeur
Le_Coeur

Reputation: 1541

Create multiple docker containers by running same docker-compose config

I'm using docker-compose to start a job on a remote server:

version: "3.9"
services:
  solution-app:
    container_name: solution_new_name_v3
    build: .

I ran the following command to deploy the container:

docker-compose -H "ssh://..." up -d --build

This works great, now I wanted to start another job in parallel using the same docker compose file, but with some minor changes in the source code. So I changed the container_name in the compose config and assumed that it should start a new container. However, instead of starting a new container my previous container was stopped and replaced with a new one with this new name.

So my question is: how can I start few containers running in parallel using same docker-compose config?

Upvotes: 1

Views: 1733

Answers (1)

Le_Coeur
Le_Coeur

Reputation: 1541

I figure out the way: so Docker compose maps all services based on the project name, which is by default a directory name. To override the project name one can use: docker-compose -p NAME

Alternatively one can set COMPOSE_PROJECT_NAME env variable

Upvotes: 6

Related Questions