I've ran into some issue, where Traefik does not want to behave when using docker stack deploy.
This is a quick post, on how I was able to launch Traefik as my reverse proxy to my Ghost Blog:
Deploy Traefik:
Create the Overlay Network:
$ docker network create --driver overlay docknet
Create the Traefik Service using docker service create:
$ docker service create --name traefik \
--constraint 'node.role==manager' \
--publish 80:80 --publish 8080:8080 \
--mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
--network docknet gilir/rpi-traefik:latest \
--docker --docker.swarmmode --docker.watch --logLevel=DEBUG \
--web
Deploy the Web Application:
Create the compose file for our Ghost Blog:
$ cat swarm-blog.yml
version: "3.4"
services:
pistack:
image: alexellis2/ghost-on-docker:armv7
networks:
- docknet
volumes:
- type: bind
source: /mnt/volumes/ghost/content/data
target: /var/www/ghost/content/data
deploy:
replicas: 1
labels:
- "traefik.enable=true"
- "traefik.backend=pistack"
- "traefik.port=2368"
- "traefik.frontend.rule=Host:blog.pistack.co.za"
update_config:
parallelism: 2
delay: 10s
restart_policy:
condition: on-failure
placement:
constraints: [node.role == manager]
networks:
docknet:
external: true
Deploy the Blog Stack:
$ docker stack deploy -c swarm-blog.yml blogs
Verify that everything is working:
$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
r5x1bpae7x86 blogs_pistack replicated 1/1 alexellis2/ghost-on-docker:armv7
rbekker87/redis:alpine-armhf
esokgi7hh9ok traefik replicated 1/1 gilir/rpi-traefik:latest *:80->80/tcp,*:8080->8080/tcp
Testing via curl:
$ curl -i http://blog.pistack.co.za
HTTP/1.1 200 OK