Skip to content

Instantly share code, notes, and snippets.

@xissy
Last active August 20, 2017 05:31
Show Gist options
  • Save xissy/332656ce2694c171afebca70dae5787c to your computer and use it in GitHub Desktop.
Save xissy/332656ce2694c171afebca70dae5787c to your computer and use it in GitHub Desktop.
Traefik with Docker Swarm and TLS
docker service create \
--network traefik-net \
--name gogs \
--mount src=gogs,dst=/data \
--constraint node.hostname=="hostname-1" \
--label traefik.port=3000 \
--label traefik.frontend.rule=Host:git.xxx.com \
gogs/gogs
docker service create \
--network traefik-net \
--name jenkins \
--mount src=jenkins,dst=/var/jenkins_home \
--constraint node.hostname=="hostname-1" \
--label traefik.port=8080 \
--label traefik.frontend.rule=Host:jenkins.xxx.com \
jenkins/jenkins:2.74-alpine
docker service create \
--network traefik-net \
--name registry \
--mount src=registry,dst=/var/lib/registry \
--constraint node.hostname=="hostname-1" \
--label traefik.port=5000 \
--label traefik.frontend.rule=Host:registry.xxx.com \
registry:2
docker service create \
--name traefik \
--constraint=node.role==manager \
--publish 80:80 --publish 443:443 --publish 18080:8080 \
--mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
--mode=global \
--network traefik-net \
--secret source=ca.crt,target=/etc/traefik/tls/ca.crt \
--secret source=ca.key,target=/etc/traefik/tls/ca.key \
traefik:v1.3.5-alpine \
--entryPoints='Name:http Address::80 Redirect.EntryPoint:https' \
--entryPoints='Name:https Address::443 TLS:/etc/traefik/tls/ca.crt,/etc/traefik/tls/ca.key' \
--defaultEntryPoints='http,https' \
--docker \
--docker.swarmmode \
--docker.domain=traefik \
--docker.watch \
--web
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment