Domain configuration

Getting started

Add a label under the deploy key in your project compose file to expose your service on the desired domain. Traefik will pick up any changes to updating services so whenever you redeploy, Traefik will try to create SSL certificates using Let's Encrypt if they don't exist already.

Compose files are compatible with environment variables. Place a .env file next to the docker-compose.yml project file to use the environment variables.

Example project compose file



version: '3.7'
build: .
image: ${SWARMLET_REGISTRY}/my-website-frontend
- traefik-public
mode: replicated
replicas: 1
- traefik.enable=true
- traefik.tags=traefik-public
- traefik.swarmlet-registry.enable=true
- traefik.swarmlet-registry.port=5000
- traefik.swarmlet-registry.frontend.rule=Host:${THE_DOMAIN}
- traefik.swarmlet-registry.frontend.entryPoints=http,https
- traefik.swarmlet-registry.frontend.passHostHeader=true
- traefik.swarmlet-registry.frontend.headers.SSLRedirect=true
- traefik.swarmlet-registry.frontend.headers.SSLHost=${THE_DOMAIN}
- traefik.swarmlet-registry.frontend.headers.STSIncludeSubdomains=true
- traefik.swarmlet-registry.frontend.headers.STSPreload=true
external: true

Updating a domain

Maybe you want to host the registry on a different domain, instead of the default registry.${ROOT_DOMAIN}. To update any module, simply git pull the modules' repository, edit the configuration, commit and push to redeploy. Another option would be to use a service like Swarmpit or Portainer to redeploy using a web interface.

Example: Changing the exposed internal registry URL to

git clone git@swarm:registry
cd registry
### edit '.env' and 'docker-compose.yml'
git add . && git commit -m 'update'
git push origin master
# $ ...
# $ remote: Stack deployed:
# $ remote: [registry] —

Try it out:

docker login
$ Username: <provide username configured during installation>
$ Password: <provide password configured during installation>
$ Login Succeeded