# Cannot run multiple docker compose on centos7

**URL:** <https://forums.docker.com/t/cannot-run-multiple-docker-compose-on-centos7/144416>\
**Category:** Compose\
**Tags:** docker\
**Created:** [October 16, 2024, 4:31am UTC](https://forums.docker.com/t/cannot-run-multiple-docker-compose-on-centos7/144416 "2024-10-16T04:31:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lixiaochuan](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/lixiaochuan/32/52668_2.png) [@lixiaochuan](https://forums.docker.com/u/lixiaochuan)\
**Post date:** [October 16, 2024, 4:31am UTC](https://forums.docker.com/t/cannot-run-multiple-docker-compose-on-centos7/144416/1 "2024-10-16T04:31:00Z")

</div>

I have two nuxt projects, so I have two docker-compose.yml files. I put them in different paths. I enter the two paths and start them using the command `docker compose up -d`. But I found that when I start the second one, the first project will be replaced. When I go back to start the first project again, the second project will be replaced. 🤣Why is this?  
Below are my two docker-compose.yml files.

```yml
services:
  frontend:
    build:
      context: .
    container_name: nuxt_1
    restart: on-failure
    ports:
      - '3010:3010'
    networks:
      - nuxt_1
    healthcheck:
      test: ['CMD', 'curl', '-f', 'http://localhost:3010/']
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
    extra_hosts:
      - 'host.docker.internal:host-gateway' # 使得容器可以通过 host.docker.internal 访问宿主机的网络

networks:
  nuxt_1:
    driver: bridge

```

```yml
services:
  frontend:
    build:
      context: .
    container_name: nuxt_2
    restart: on-failure
    ports:
      - '3011:3011'
    networks:
      - nuxt_2
    healthcheck:
      test: ['CMD', 'curl', '-f', 'http://localhost:3011/']
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
    extra_hosts:
      - 'host.docker.internal:host-gateway' # 使得容器可以通过 host.docker.internal 访问宿主机的网络

networks:
  nuxt_2:
    driver: bridge

```

This is my system information:

```shell
CentOS Linux release 7.9.2009 (Core)
3.10.0-1160.76.1.el7.x86_64
Docker version 26.1.4, build 5650f9b

```

I asked github copilot chat, and it said it might be a network problem, but after I modified the network it still didn’t work. It might also be a system resource limit such as memory, but this is a new server, and there are a lot of idle memory, CPU and other resources.

Finally, my two docker composes both use the host’s redis:6379. Will this cause this problem? In addition, I did not download docker-compose because docker compose is built-in after docker version 20, so I have always used docker cli to run docker compose.

Looking forward to your reply.

---

<div class="post-metadata">

**Author:** ![deanayalon](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/deanayalon/32/49113_2.png) [@deanayalon](https://forums.docker.com/u/deanayalon)\
**Post date:** [October 16, 2024, 7:20am UTC](https://forums.docker.com/t/cannot-run-multiple-docker-compose-on-centos7/144416/2 "2024-10-16T07:20:31Z")

</div>

The services only replace each other if they have the same service and project name

The default project name is the name of the directory the compose file is in

So either:  
A. The compose files are within directories of the same name - In this case, add the `name` property to choose the project name  
B. You have the `COMPOSE_PROJECT_NAME` environment variable set, which affects both files

---

<div class="post-metadata">

**Author:** ![lixiaochuan](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/lixiaochuan/32/52668_2.png) [@lixiaochuan](https://forums.docker.com/u/lixiaochuan)\
**Post date:** [October 16, 2024, 8:22am UTC](https://forums.docker.com/t/cannot-run-multiple-docker-compose-on-centos7/144416/3 "2024-10-16T08:22:45Z")

</div>

Thanks for your answer, the parent folder of my docker-compose.yml did have the same name, I solved this problem by using `docker compose -p`

---

<div class="post-metadata">

**Author:** ![deanayalon](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/deanayalon/32/49113_2.png) [@deanayalon](https://forums.docker.com/u/deanayalon)\
**Post date:** [October 16, 2024, 10:02am UTC](https://forums.docker.com/t/cannot-run-multiple-docker-compose-on-centos7/144416/4 "2024-10-16T10:02:41Z")

</div>

Also an option, just make sure to always remember to set that flag, or just define it in the compose file with the name property

After all, compose was made specifically so you do not have to specify many flags in the run command, so why specify those in the compose command?

---

<div class="post-metadata">

**Author:** ![lixiaochuan](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/lixiaochuan/32/52668_2.png) [@lixiaochuan](https://forums.docker.com/u/lixiaochuan)\
**Post date:** [October 16, 2024, 10:23am UTC](https://forums.docker.com/t/cannot-run-multiple-docker-compose-on-centos7/144416/5 "2024-10-16T10:23:14Z")

</div>

Yes, using `name` is more elegant. I have added the `name` option to my compose file.
