Docker: Traefik and Docker Compose naming good practices
This documentation is part of the HTTPS Routing guide. You can view the complete guide here: How to manage HTTP routing and TLS encryption (HTTPS) in your Docker containers.
Welcome to the Stackhero documentation
Stackhero offers a ready-to-use Docker cloud CaaS (Containers as a Service) platform, designed for fast and reliable container deployments:
- Deploy to production with a single
docker-compose upcommand. No additional configuration is required: simply start your containers.- Choose your own domain name, automatically secured with HTTPS (for example: https://api.your-company.com, https://www.your-company.com, or https://backoffice.your-company.com).
- Benefit from high performance and enhanced security on private, dedicated infrastructure.
- Apply updates with a single click for straightforward, effortless maintenance.
Your containers can be live in production in around five minutes. Stackhero manages the infrastructure, updates, and security for you, so you can focus on developing your applications. Find out more about Docker CaaS cloud hosting.
When defining a container in your docker-compose.yml file, a few fields are important for better consistency and ease of management. Consider using the following recommended configuration:
services:
<CONTAINER_NAME>:
image: traefik/whoami
hostname: <CONTAINER_NAME>
container_name: <CONTAINER_NAME>
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.routers.<CONTAINER_NAME>.rule=Host(`my-company.com`)"
- "traefik.http.routers.<CONTAINER_NAME>.tls.certresolver=letsencrypt"
Simply replace <CONTAINER_NAME> with the desired name for your container, for example frontend.