skip to Main Content

I’ve built a docker-compose.yml file however I see by default Docker Desktop App names the group of containers by parent folder name.

enter image description here

I need to change that name docker to another name

This’s my file explorer path:
enter image description here

Thanks

3

Answers


  1. You can simply use the -p flag with docker-compose up, let’s say you want to name your app stack-example

    docker-compose -p="stack-example" up
    
    Login or Signup to reply.
  2. COMPOSE_PROJECT_NAME

    Sets the project name. This value is prepended along with the service
    name to the container on start up. For example, if your project name
    is myapp and it includes two services db and web, then Compose starts
    containers named myapp_db_1 and myapp_web_1 respectively.

    Setting this is optional. If you do not set this, the
    COMPOSE_PROJECT_NAME defaults to the basename of the project
    directory.

    You can either set it by mentioning it in the .env file or while executing the docker-compose file.

    By mentioning it in .env file

    Create a .env file in the directory where docker-compose file is present and add the following statement.

    COMPOSE_PROJECT_NAME = <project_name>
    

    By mentioning it while executing the docker-compose file with the help of flag -p

    docker-compose -f <docker_compose_file> -p "<project_name>" up
    
    Login or Signup to reply.
  3. declare name in the docker-compose.yml file and make sure to run as docker compose ... not docker-compose .... source: https://github.com/docker/compose/issues/1123#issuecomment-1130002420

    name: project-name
    services:
      app:
        build:
          context: .
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search