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.
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
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:
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.