From 78312c01b1dc71149c07c3a99b76f84e1bcf0fa8 Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Sat, 31 Dec 2022 03:30:26 +0900 Subject: [PATCH] create traefik --- traefik/compose.yml | 17 +++++++++++++++++ traefik/traefik.yml | 5 +++++ 2 files changed, 22 insertions(+) create mode 100644 traefik/compose.yml create mode 100644 traefik/traefik.yml diff --git a/traefik/compose.yml b/traefik/compose.yml new file mode 100644 index 0000000..83f0f1a --- /dev/null +++ b/traefik/compose.yml @@ -0,0 +1,17 @@ +services: + traefik: + image: traefik:v2.9 + ports: + - "80:80" + - "8080:8080" + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ./traefik.yml:/etc/traefik/traefik.yml + + # Traefikでのサービス名は {Docker Composeでのサービス名}-{Docker Composeでのプロジェクト名} のようになる + # https://github.com/traefik/traefik/blob/e54ee89330a800d509da7b11b46a6ecbb331e791/pkg/provider/docker/config.go#L412-L420 + # そうでない場合はコンテナ名 + # --providers.docker.defaultRule: Host(`{{ .Name }}.localhost`) + # … {{ .Name }} はTraefikでのサービス名に置換される + nginx: + image: nginx:alpine diff --git a/traefik/traefik.yml b/traefik/traefik.yml new file mode 100644 index 0000000..682c690 --- /dev/null +++ b/traefik/traefik.yml @@ -0,0 +1,5 @@ +api: + insecure: true +providers: + docker: + defaultRule: Host(`{{ .Name }}.localhost`)