Deploy Traefik with TLS on Docker with simplecontainer
All examples are available at the Github.
Traefik can be used as a traffic router on the Docker daemon. It has a way to handle Entrypoints, Routers and Middlewares.
Deployment process of the Traefik with automatic TLS on the simplecontainer is pretty straightforward.
First we need to create Resource holding static configuration for the Traefik.
⚠️
Be sure to replace email@example.com with your own email address.
Afterwards, we need to create containers definition.
⚠️
Be sure to create a directory
~/letsencrypt
on your host running simplecontainer!Now apply these definitions.
smr apply https://raw.githubusercontent.com/simplecontainer/examples/refs/heads/main/traefik/resource-traefik.yaml
smr apply https://raw.githubusercontent.com/simplecontainer/examples/refs/heads/main/traefik/containers.yaml
GROUP NAME DOCKER NAME IMAGE IP PORTS DEPS DOCKER STATE SMR STATE
traefik traefik traefik-traefik-1 traefik:v2.5 80:80, 443:443 running running (1s)
As you can see Traefik is up and running. Now we will deploy nginx container and expose it via Traefik we just deployed.
⚠️
Be sure to replace example.com with your own public domain for this to work!
Applying this definition will deploy the Nginx which is exposed via Traefik.
smr apply https://raw.githubusercontent.com/simplecontainer/examples/refs/heads/main/traefik/container-service.yaml
smr ps
GROUP NAME DOCKER NAME IMAGE IP PORTS DEPS DOCKER STATE SMR STATE
examples nginx examples-nginx-1 nginx:latest 8080 running running (12s)
traefik traefik traefik-traefik-1 traefik:v2.5 80:80, 443:443 running running (6m1s)
Afterward, access to the Nginx web server can be made via https://example.com