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
HTTP routing with Traefik: Update guide to include DHI (#23769)
<!--Delete sections as needed -->
## Description
<!-- Tell us what you did and why -->
## Related issues or tickets
<!-- Related issues, pull requests, or Jira tickets -->
## Reviews
<!-- Notes for reviewers here -->
<!-- List applicable reviews (optionally @tag reviewers) -->
- [ ] Technical review
- [x] Editorial review
- [ ] Product review
---------
Signed-off-by: MohammadHasan Akbari <jarqvi.jarqvi@gmail.com>
@@ -47,18 +47,78 @@ 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. These commands 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.
51
+
52
+
{{< tabs >}}
53
+
{{< tab name="Using Docker Hardened Images" >}}
54
+
55
+
Docker Hardened Images (DHI) for Traefik are available on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/traefik).
56
+
If you haven't authenticated yet, first run:
57
+
58
+
```bash
59
+
$ docker login dhi.io
60
+
```
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
+
dhi.io/traefik:3.6.2 \
69
+
--providers.docker
70
+
```
71
+
72
+
{{< /tab >}}
73
+
74
+
{{< tab name="Using the official image" >}}
75
+
76
+
You can also use the official image from Docker Hub:
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
90
91
+
{{< tabs >}}
92
+
{{< tab name="Using Docker Hardened Images" >}}
93
+
94
+
Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx).
95
+
If you haven't authenticated yet, first run:
96
+
97
+
```bash
98
+
$ docker login dhi.io
99
+
```
100
+
58
101
```console
59
-
$ docker run -d --network=traefik-demo --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' nginx
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
123
64
124
4. Start a second application that will use a different hostname.
@@ -83,6 +143,24 @@ The application can be accessed on GitHub at [dockersamples/easy-http-routing-wi
83
143
84
144
1. In the `compose.yaml` file, Traefik is using the following configuration:
85
145
146
+
{{< tabs >}}
147
+
{{< tab name="Using DHI image" >}}
148
+
149
+
```yaml
150
+
services:
151
+
proxy:
152
+
image: dhi.io/traefik:3.6.2
153
+
command: --providers.docker
154
+
ports:
155
+
- 80:80
156
+
volumes:
157
+
- /var/run/docker.sock:/var/run/docker.sock
158
+
```
159
+
160
+
{{< /tab >}}
161
+
162
+
{{< tab name="Using official image" >}}
163
+
86
164
```yaml
87
165
services:
88
166
proxy:
@@ -94,21 +172,55 @@ The application can be accessed on GitHub at [dockersamples/easy-http-routing-wi
94
172
- /var/run/docker.sock:/var/run/docker.sock
95
173
```
96
174
175
+
{{< /tab >}}
176
+
{{< /tabs >}}
177
+
97
178
Note that this is essentially the same configuration as used earlier, but now in a Compose syntax.
98
179
99
180
2. The client service has the following configuration, which will start the container and provide it with the labels to receive requests at localhost.
100
181
101
-
```yaml {hl_lines=[7,8]}
182
+
{{< tabs >}}
183
+
{{< tab name="Using Docker Hardened Images" >}}
184
+
185
+
Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx).
186
+
187
+
If you haven't authenticated yet, first run:
188
+
189
+
```bash
190
+
$ docker login dhi.io
191
+
```
192
+
193
+
You can use it as your base image as shown following:
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
225
114
226
```yaml {hl_lines=[7,8]}
@@ -138,7 +250,7 @@ The application can be accessed on GitHub at [dockersamples/easy-http-routing-wi
138
250
139
251
5. Before starting the stack, stop the Nginx container if it is still running.
140
252
141
-
And that’s it. Now, you only need to spin up the Compose stack with a `docker compose up` and all of the services and applications will be ready for development.
253
+
And that’s it. Now, you only need to spin up the Compose stack with a `docker compose up` and all of the services and applications will be ready for development.
142
254
143
255
## Sending traffic to non-containerized workloads
144
256
@@ -176,18 +288,41 @@ With this file, the only change is to the Compose configuration for Traefik. The
176
288
1. The configuration file is mounted into the Traefik container (the exact destination path is up to you)
177
289
2. The `command` is updated to add the file provider and point to the location of the configuration file
0 commit comments