version: '3.8' services: traefik: image: traefik:v3.0 container_name: traefik networks: - traefik-net ports: - "80:80" - "8880:8080" # network_mode: "host" # 主机网络模式 volumes: - ./traefik.yml:/etc/traefik/traefik.yml - ./dynamic.yml:/etc/traefik/dynamic.yml # 动态配置文件 restart: always whoami: image: traefik/whoami labels: - "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)" # 2. Nacos 服务监听脚本 # nacos-cluster-watcher: # user: "root" # privileged: true # image: node:24.8.0-alpine3.21 # container_name: nacos-cluster-watcher # # network_mode: "host" # networks: # - traefik-net # working_dir: /app # volumes: # - ./:/app # 挂载当前目录到容器 # command: sh -c "npm install && node src/index.js" # restart: always networks: traefik-net: driver: bridge