You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -47,17 +47,71 @@ Let’s do a quick demo of starting Traefik and then configuring two additional
47
47
$ docker network create traefik-demo
48
48
```
49
49
50
-
2. Start a Traefik container using the following command. The command exposes Traefik on port 80, mounts the Docker socket (which is used to monitor containers to update configuration), and passes the `--providers.docker` argument to configure Traefik to use the Docker provider.
50
+
2. Start a Traefik container using one of the following methods.
Docker Hardened Images (DHI) for Traefik are available on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/traefik).
56
+
Before you can use a DHI image, you must mirror it into your organization’s namespace.
57
+
Follow the [DHI quickstart](/dhi/get-started/) to create a mirrored repository.
58
+
59
+
For example — use:
60
+
`FROM <your-namespace>/dhi-traefik:<tag>`
61
+
62
+
Then start a container using the Hardened image:
63
+
64
+
```console
65
+
$ docker run -d --network=traefik-demo \
66
+
-p 80:80 \
67
+
-v /var/run/docker.sock:/var/run/docker.sock \
68
+
<your-namespace>/dhi-traefik:3.6.2 \
69
+
--providers.docker
70
+
```
71
+
72
+
{{< /tab >}}
73
+
{{< tab name="Using the official image" >}}
74
+
75
+
You can also use the official image from Docker Hub:
76
+
77
+
```console
78
+
$ docker run -d --network=traefik-demo \
79
+
-p 80:80 \
80
+
-v /var/run/docker.sock:/var/run/docker.sock \
81
+
traefik:v3.6.2 \
82
+
--providers.docker
83
+
```
84
+
85
+
{{< /tab >}}
86
+
{{< /tabs >}}
55
87
56
88
3. Now, start a simple Nginx container and define the labels Traefik is watching for to configure the HTTP routing. Note that the Nginx container is not exposing any ports.
57
89
58
-
```console
59
-
$ docker run -d --network=traefik-demo --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' nginx
60
-
```
90
+
{{< tabs >}}
91
+
{{< tab name="Using Docker Hardened Images" >}}
92
+
93
+
If your organization uses an [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx),
94
+
you can use the mirrored image name below. For example:
Once the container starts, open your browser to [http://nginx.localhost](http://nginx.localhost) to see the app (all Chromium-based browsers route \*.localhost requests locally with no additional setup).
63
117
@@ -83,31 +137,74 @@ The application can be accessed on GitHub at [dockersamples/easy-http-routing-wi
83
137
84
138
1. In the `compose.yaml` file, Traefik is using the following configuration:
85
139
86
-
```yaml
87
-
services:
88
-
proxy:
89
-
image: traefik:v3.6.2
90
-
command: --providers.docker
91
-
ports:
92
-
- 80:80
93
-
volumes:
94
-
- /var/run/docker.sock:/var/run/docker.sock
95
-
```
140
+
{{< tabs >}}
141
+
{{< tab name="Using DHI image" >}}
142
+
143
+
```yaml
144
+
services:
145
+
proxy:
146
+
image: <your-namespace>/dhi-traefik:3.6.2
147
+
command: --providers.docker
148
+
ports:
149
+
- 80:80
150
+
volumes:
151
+
- /var/run/docker.sock:/var/run/docker.sock
152
+
```
153
+
154
+
{{< /tab >}}
155
+
{{< tab name="Using official image" >}}
156
+
157
+
```yaml
158
+
services:
159
+
proxy:
160
+
image: traefik:v3.6.2
161
+
command: --providers.docker
162
+
ports:
163
+
- 80:80
164
+
volumes:
165
+
- /var/run/docker.sock:/var/run/docker.sock
166
+
```
167
+
168
+
{{< /tab >}}
169
+
{{< /tabs >}}
96
170
97
171
Note that this is essentially the same configuration as used earlier, but now in a Compose syntax.
98
172
99
173
2. The client service has the following configuration, which will start the container and provide it with the labels to receive requests at localhost.
3. The api service has a similar configuration, but you’ll notice the routing rule has two conditions - the host must be “localhost” and the URL path must have a prefix of “/api”. Since this rule is more specific, Traefik will evaluate it first compared to the client rule.
113
210
@@ -176,6 +273,26 @@ With this file, the only change is to the Compose configuration for Traefik. The
176
273
1. The configuration file is mounted into the Traefik container (the exact destination path is up to you)
177
274
2. The `command` is updated to add the file provider and point to the location of the configuration file
0 commit comments