Search code examples
dockerdocker-composedockerfile

docker-compose change name of main container


I have a simple frontend and backend app. And I have a docker-compose file but it's inside frontend folder. So when I run it both frontend and backend containers are under frontend container (it takes name of the folder) how can I rename this main container? I am using version 3.9

version: "3.9"
services:
  be_service:
    container_name: backend
    build:
      context: ../backend
      dockerfile: ./Dockerfile
    ports:
      - "8089:8080"
  fe_service:
    container_name: frontend
    build:
      context: ./
      dockerfile: ./Dockerfile
    ports:
      - "8088:80"
    depends_on:
      - be_service

Solution

  • Related to Docker Compose docs you can set your project name with:

    docker-compose -p app up --build
    

    with -p app to set your compose container name to app.