sh.osa.cubetiqs.com/traefik-docker.sh

73 lines
1.4 KiB
Bash

#!/bin/bash
NAME=traefik
NETWORK_NAME=traefik-net
TRAEFIK_IP=172.19.0.5
TRAEFIK_HTTP=80
TRAEFIK_HTTPS=443
TRAEFIK_CONFIG=traefik.yml
cat <<EOF> $TRAEFIK_CONFIG
global:
checkNewVersion: true
sendAnonymousUsage: true
entryPoints:
web:
address: ':80'
websecure:
address: ':443'
metrics:
address: ':8082'
accessLog: {}
tracing: {}
metrics:
prometheus:
entryPoint: metrics
addEntryPointsLabels: true
addServicesLabels: true
addRoutersLabels: true
log:
filePath: /data/log/traefik.log
format: json
api:
insecure: true
dashboard: true
providers:
docker:
network: $NETWORK_NAME
exposedByDefault: false
watch: true
certificatesResolvers:
myresolver:
acme:
email: ''
storage: /data/acme.json
httpChallenge:
entryPoint: web
EOF
docker rm -f $NAME
if [ ! "$(docker network ls | grep $NETWORK_NAME)" ]; then
docker network create --subnet=172.19.0.0/24 --gateway=172.19.0.1 $NETWORK_NAME
fi
docker run -d -p 8082:8082 -p 8080:8080 -p $TRAEFIK_HTTP:80 -p $TRAEFIK_HTTPS:443 \
--restart always --name $NAME \
--ip $TRAEFIK_IP \
--network $NETWORK_NAME \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $PWD/data:/data \
-v $PWD/traefik.yml:/etc/traefik/traefik.yml traefik:v3.0