如何在启用 swarm 的情况下使用 traefik 处理两个单独的 docker-compose 文件

how to work two seperate docker-compose files with traefik where swarm enabled

我有两个不同的 docker-compose 文件具有不同的服务(项目 space),我想在同一个群上 运行 因为我想使用 traefik 作为反向代理如何我可以这样做吗?

在部署到 swarm 之前,您必须使用通用镜像注册表和预构建镜像:

第一个撰写文件:

services:
    my_service:
        build: ./my_service
        image: my-registry-host/my_service:latest
        ...

第二个撰写文件:

services:

    my_other_service:
        build: ./my_other_service
        image: my-registry-host/my_other_service:latest
        ...
    my_service:
        image: my-registry-host/my_service:latest
        ...

    traefik:
        image: traefik:v2.0
        ...

当您在第一个文件中构建服务时,它们会上传到您的公共注册表 my-registry-host。当您部署第二个文件时,您会看到图像将从公共注册表中获取,并且堆栈按预期运行。