Domains
Configure domains for your Docker Compose application.
When using Docker Compose, adding a domain to a service is a straightforward process. This guide will walk you through the necessary steps to configure manual domains for your application.
Key Steps:
- Add the service to the
dokploy-network
. - Use Traefik labels to configure routing.
Attention
Since v0.7.0 Dokploy support domains natively. This means that you can configure your domain directly in the Dokploy UI, without doing the rest of the steps check on the domains section.
Example Scenario
Let's consider an application with three components: a frontend, a backend, and a database. We'll start with a basic Docker Compose file and then enhance it with domain configuration.
Step 1: Add the Network
First, we'll add the dokploy-network to our services:
Step 2: Configuring Traefik Labels
Now, let's add Traefik labels to route domains to our services. We'll focus on the frontend and backend services:
Understanding Traefik Labels
traefik.enable=true
Enables Traefik routing for the service.traefik.http.routers.<UNIQUE-RULE>.rule=Host('your-domain.dokploy.com')
Specifies the domain for the servicetraefik.http.routers.<UNIQUE-RULE>.entrypoints=web
Sets the service to be accessible via HTTP.traefik.http.services.<UNIQUE-RULE>.loadbalancer.server.port=3000
Specifies the port your service is using internally.
Note: Replace <UNIQUE-RULE>
with a unique identifier for each service (e.g., frontend-app, backend-app, etc.).
Important Considerations
- Port Exposure: Use
expose
instead ofports
to expose ports to the host machine. This ensures that the ports are not exposed to the host machine. - DNS Configuration: Ensure you create
A
records pointing to your domain in your DNS Provider Settings. - HTTPS: For HTTPS, you can use Let's Encrypt or other SSL/TLS certificates.
Deployment
With these configurations in place, you're now ready to deploy your application using Docker Compose. This setup should be sufficient to get your services up and running with custom domain routing through Traefik.
If you have any further questions or need assistance, join our Discord server and we'll be happy to help.