Why does docker compose confuse with the same service name in two different docker-compose.yml files (for 2 different apps) - St

I want to start two apps on the same machine, one is ragflow the other is dify. Their docker-compose.ya

I want to start two apps on the same machine, one is ragflow the other is dify. Their docker-compose.yaml files both define the redis service.

Ragflow defines as following

  redis:
    # swr-north-4.myhuaweicloud/ddn-k8s/docker.io/valkey/valkey:8
    image: valkey/valkey:8
    container_name: ragflow-redis
    command: redis-server --requirepass ${REDIS_PASSWORD} --maxmemory 128mb --maxmemory-policy allkeys-lru
    env_file: .env
    ports:
      - ${REDIS_PORT}:6379
    volumes:
      - redis_data:/data
    networks:
      - ragflow
    restart: on-failure

Dify defines as following

  redis:
    image: redis:6-alpine
    restart: always
    environment:
      REDISCLI_AUTH: ${REDIS_PASSWORD:-difyai123456}
    volumes:
      # Mount the redis data directory to the container.
      - ./volumes/redis/data:/data
    # Set the redis password when startup redis server.
    command: redis-server --requirepass ${REDIS_PASSWORD:-difyai123456}
    healthcheck:
      test: [ 'CMD', 'redis-cli', 'ping' ]

I first started ragflow and set redis to map to host the port 6378, as docker ps show

92660bc83fb4   valkey/valkey:8  ...  0.0.0.0:6378->6379/tcp, [::]:6378->6379/tcp ragflow-redis                                                                                

I then started dify, but to my surprise it output

...
 ✔ Container ragflow-redis           Recreated                                                                                                                                 
 ✔ Container docker-redis-1          Started 

I then docker composer down them both, and started dify first then ragflow, but this time ragflow output

 ✔ Container docker-redis-1  Recreated                                                                                                                                        
 ✔ Container ragflow-redis   Started

Then I had thought maybe it was because dify's docker-composer.yaml did not define a container_name for redis, so I added container_name: dify-redis for it. But that did not work, when I start dify then ragflow, I still saw the output

 ✔ Container dify-redis      Recreated                                                                                                                                       
 ✔ Container ragflow-server  Started  

Only after I start them using --project-name they did start successfully.

docker compose --project-name dify up -d
docker compose --project-name ragflow up -d

But why does docker composer confuse them ? I check each networks setting and did not understand the reason.

# for ragflow
networks:
  ragflow:
    driver: bridge

# for dify
networks:
  ssrf_proxy_network:
    driver: bridge
    internal: true
  milvus:
    driver: bridge
  opensearch-net:
    driver: bridge
    internal: true

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744250749a4565156.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信