
traefik负载均衡/滚动升级
docker-compose.yml
version : '3' services: reverse-proxy: # The official v2 Traefik docker image image: traefik:v2.10 # Enables the web UI and tells Traefik to listen to docker command: # insecure - --api.insecure=true - --providers.docker # Create an entrypoint "http" listening on port 80 - --entrypoints.http.address=:80 # Create an entrypoint "https" listening on port 443 - --entrypoints.https.address=:443 - --providers.file.directory=/etc/traefik/ - --providers.file.watch=true ports: # The HTTP port - "80:80" - "443:443" # The Web UI (enabled by --api.insecure=true) - "8080:8080" volumes: # So that Traefik can listen to the Docker events - /var/run/docker.sock:/var/run/docker.sock - ./traefik/:/etc/traefik/ whoami: # A container that exposes an API to show its IP address image: traefik/whoami ports: - "8081:80" labels: - "traefik.http.routers.whoami.rule=Host(`hk.peos.cn:8081`)" whoami2: # A container that exposes an API to show its IP address image: traefik/whoami ports: - "8082:80" labels: - "traefik.http.routers.whoami.rule=Host(`hk.peos.cn:8082`)"
./traefik.yml:
http: routers: prod-router: rule: "Path(`/prod`)" service: load-service services: load-service: loadBalancer: healthCheck: path: /health interval: 2s timeout: 2s servers: - url: "http://hk.peos.cn:8082/" - url: "http://hk.peos.cn:8081" tls: certificates: - certFile: "/etc/certs/hk.peos.cn.cer" keyFile: "/etc/certs/hk.peos.cn.key"
publish.sh
echo upgrade api-1 docker-compose stop api-1 docker-compose rm -f api-1 docker-compose build --no-cache api-1 docker-compose up -d api-1 sleep 10 echo upgrade api-2 docker-compose stop api-2 docker-compose rm -f api-2 docker-compose build --no-cache api-2 docker-compose up -d api-2 echo success
corresponding errors:
- traefik file watch not working in docker (Traefik only support directory and must mounted a folder to container.)
============ 欢迎各位老板打赏~ ===========


与本文相关的文章
- · docker安装 Confluence9
- · 单台服务器应用不中断服务热部署滚动更新方案
- · docker安装code-server
- · Docker 镜像加速列表(20250216已更新)
- · 解决docker push 到私有registry时,报unknown blob错
- · Amazon Linux 2023 安装Docker和Docker Compose
- · 修改Docker的默认网段
- · docker定时任务Mysql脚本
- · 解决Linux实例磁盘空间满问题
- · failed to fetch metadata: fork/exec /home/appuser/.docker/cli-plugins/docker-buildx: exec format error
- · Docker登录login报错Error saving credentials
- · docker安装mysql8注意事项