twn39 / code

:memo: 代码笔记,通过 issue 的方式记录日常遇到的问题和学习笔记
13 stars 1 forks source link

Traefik 配置 #401

Open twn39 opened 2 years ago

twn39 commented 2 years ago

安装 traefik,文件:docker-compose.yml

version: '3'

services:
  traefik-server:
    # The official v2 Traefik docker image
    image: traefik:v2.6
    # Enables the web UI and tells Traefik to listen to docker
    command: --api.insecure=true --providers.docker
    ports:
      # The HTTP port
      - "80:80"
      # The Web UI (enabled by --api.insecure=true)
      - "8030:8080"
    networks:
      - worknet
    volumes:
      # So that Traefik can listen to the Docker events
      - /var/run/docker.sock:/var/run/docker.sock

networks:
  worknet:
    name: worknet

启动:

docker-compose up -d traefik-server

添加 service:

docker run -d --name adminer-ui --link mariadb-server:db -p 8070:8080 --network worknet -l 'traefik.http.routers.adminer.rule=PathPrefix(`/adminer`)' adminer

通过 rule 将 adminer 访问路径挂载到 traefik localhst:80/adminer 子目录下。