Set up Traefik to automatically proxy a web application running inside a Docker container to an arbitrary hostname (e.g. echo.mydomain.com
):
Instantiate a Docker image, giving it a name matching your desired hostname:
docker run -d --name echo hashicorp/http-echo -text="Hello, World!"
Run Traefik with a defaultRule
for your parent domain:
docker run -d -p 80:80 -v /var/run/docker.sock:/var/run/docker.sock:ro traefik:2 --providers.docker --providers.docker.defaultRule='Host(`{{ .Name }}.mydomain.com`)'