Skip to content

Commit f846f45

Browse files
Update docker-pad.md
1 parent 386965b commit f846f45

1 file changed

Lines changed: 53 additions & 49 deletions

File tree

content/en/docs/deployment/docker-deploy/docker-pad.md

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -289,67 +289,71 @@ To configure Nginx, perform the following steps:
289289

290290
This configuration exposes only port 80 publicly while acting as a proxy to your app on the internal port 8080.
291291

292-
### Traefik Configuration
292+
### Configuring Traefik
293293

294-
To set up Traefik as a reverse proxy for your app running in a Docker container, use Docker Compose for simplicity. This configuration exposes Traefik on ports 80/8080, automatically discovers your app container via labels, and routes traffic to it.
295-
Traefik uses two networks: frontend (public) and backend (internal). Add Traefik labels to the app service.
294+
To simplify setting up Traefik as a reverse proxy for your app running in a Docker container, use Docker Compose. This configuration exposes Traefik on ports `80/8080`, automatically discovers your app container through labels, and routes traffic to it.
296295

297-
```
298-
services:
299-
traefik:
300-
image: traefik:v3.0
301-
ports:
302-
- "80:80"
303-
- "8080:8080" # Traefik dashboard
304-
volumes:
305-
- /var/run/docker.sock:/var/run/docker.sock:ro
306-
command:
307-
- --api.dashboard=true
308-
- --providers.docker=true
309-
- --providers.docker.exposedbydefault=false
310-
- --entrypoints.web.address=:80
311-
networks:
312-
- frontend
313-
- backend
314-
restart: unless-stopped
315-
app:
316-
build: .
317-
networks:
318-
- backend
319-
labels:
320-
- traefik.enable=true
321-
- traefik.docker.network=backend
322-
- traefik.http.routers.app.rule=Host(`localhost`) || PathPrefix(`/api`)
323-
- traefik.http.routers.app.entrypoints=web
324-
- traefik.http.services.app.loadbalancer.server.port=8080
325-
restart: unless-stopped
326-
networks:
327-
frontend:
328-
external: false
329-
backend:
330-
external: false
331-
```
332-
Run with `docker compose up -d --build`.
296+
Traefik uses two networks: *frontend* (public) and *backend* (internal).
297+
298+
1. Add Traefik labels to the app service:
333299

334-
Access your app at `http://localhost` (Traefik proxies to app:8080 internally).
300+
```
301+
services:
302+
traefik:
303+
image: traefik:v3.0
304+
ports:
305+
- "80:80"
306+
- "8080:8080" # Traefik dashboard
307+
volumes:
308+
- /var/run/docker.sock:/var/run/docker.sock:ro
309+
command:
310+
- --api.dashboard=true
311+
- --providers.docker=true
312+
- --providers.docker.exposedbydefault=false
313+
- --entrypoints.web.address=:80
314+
networks:
315+
- frontend
316+
- backend
317+
restart: unless-stopped
318+
app:
319+
build: .
320+
networks:
321+
- backend
322+
labels:
323+
- traefik.enable=true
324+
- traefik.docker.network=backend
325+
- traefik.http.routers.app.rule=Host(`localhost`) || PathPrefix(`/api`)
326+
- traefik.http.routers.app.entrypoints=web
327+
- traefik.http.services.app.loadbalancer.server.port=8080
328+
restart: unless-stopped
329+
networks:
330+
frontend:
331+
external: false
332+
backend:
333+
external: false
334+
```
335335

336-
**Key Traefik Labels Explained**
336+
2. Run the following command: `docker compose up -d --build`.
337337

338-
`traefik.enable=true`: Enables Traefik for this container.
338+
You can now access your app at `http://localhost`. Traefik proxies to `app:8080` internally.
339339

340-
`traefik.http.routers.java-app.rule=Host(yourapp.example.com)`: Routes requests matching the host to this service.
340+
#### Key Traefik Labels Explained
341341

342-
`traefik.http.services.java-app.loadbalancer.server.port=8080`: Forwards to your app's internal port.
342+
This section explains the main labels used by Traefik.
343343

344-
Traefik auto-detects changes via Docker socket; no restarts needed for label updates.
344+
* `traefik.enable=true` - Enables Traefik for this container.
345+
* `traefik.http.routers.java-app.rule=Host(yourapp.example.com)` - Routes requests matching the host to this service.
346+
* `traefik.http.services.java-app.loadbalancer.server.port=8080` - Forwards to your app's internal port.
345347

346-
**Key Differences from Nginx**
348+
Traefik automatically detects changes through a Docker socket. You do not need to restart it to update the labels.
347349

348-
No static config files—Traefik auto-configures via labels.
350+
#### Main Differences between Traefik and Nginx
349351

350-
Dashboard at `http://localhost:8080` shows routes.
352+
This section explains how Traefik proxies differ from Nginx.
351353

352-
Scale easily: duplicate `app service` with unique router rules (e.g., Host(app2.local)).​
354+
* Traefik does not use static config files. Instead, the configuration is automatic through the use of labels.
355+
* A dashboard available at `http://localhost:8080` shows the routes.
356+
* You can easily scale by duplicating the `app service` with unique router rules (for example, `Host(app2.local)`).​
353357

354358
## High Availability (sample)
355359

0 commit comments

Comments
 (0)