From 3c446a7eb36dcb06480ee0e8f80521767498ee74 Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari <116190942+jarqvi@users.noreply.github.com> Date: Mon, 24 Nov 2025 20:43:46 +0000 Subject: [PATCH 01/16] chore: use dhi in traefik guide --- content/guides/traefik.md | 174 ++++++++++++++++++++++++++++++++------ 1 file changed, 147 insertions(+), 27 deletions(-) diff --git a/content/guides/traefik.md b/content/guides/traefik.md index cb0481888742..5cd29ccc35d3 100644 --- a/content/guides/traefik.md +++ b/content/guides/traefik.md @@ -47,17 +47,71 @@ Let’s do a quick demo of starting Traefik and then configuring two additional $ docker network create traefik-demo ``` -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. +2. Start a Traefik container using one of the following methods. - ```console - $ docker run -d --network=traefik-demo -p 80:80 -v /var/run/docker.sock:/var/run/docker.sock traefik:v3.6.2 --providers.docker - ``` +{{< tabs >}} +{{< tab name="Using Docker Hardened Images" >}} + +Docker Hardened Images (DHI) for Traefik are available on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/traefik). +Before you can use a DHI image, you must mirror it into your organization’s namespace. +Follow the [DHI quickstart](/dhi/get-started/) to create a mirrored repository. + +For example — use: +`FROM /dhi-traefik:` + +Then start a container using the Hardened image: + +```console +$ docker run -d --network=traefik-demo \ + -p 80:80 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + /dhi-traefik:3.6.2 \ + --providers.docker +``` + +{{< /tab >}} +{{< tab name="Using the official image" >}} + +You can also use the official image from Docker Hub: + +```console +$ docker run -d --network=traefik-demo \ + -p 80:80 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + traefik:v3.6.2 \ + --providers.docker +``` + +{{< /tab >}} +{{< /tabs >}} 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. - ```console - $ docker run -d --network=traefik-demo --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' nginx - ``` +{{< tabs >}} +{{< tab name="Using Docker Hardened Images" >}} + +If your organization uses an [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx), +you can use the mirrored image name below. For example: + +```console +$ docker run -d --network=traefik-demo \ + --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ + /dhi-nginx:1.29.3 +``` + +{{< /tab >}} +{{< tab name="Using the official image" >}} + +You can also run the official NGINX image as follows: + +```console +$ docker run -d --network=traefik-demo \ + --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ + nginx:1.29.3 +``` + +{{< /tab >}} +{{< /tabs >}} 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). @@ -83,31 +137,74 @@ The application can be accessed on GitHub at [dockersamples/easy-http-routing-wi 1. In the `compose.yaml` file, Traefik is using the following configuration: - ```yaml - services: - proxy: - image: traefik:v3.6.2 - command: --providers.docker - ports: - - 80:80 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - ``` +{{< tabs >}} +{{< tab name="Using DHI image" >}} + +```yaml +services: + proxy: + image: /dhi-traefik:3.6.2 + command: --providers.docker + ports: + - 80:80 + volumes: + - /var/run/docker.sock:/var/run/docker.sock +``` + +{{< /tab >}} +{{< tab name="Using official image" >}} + +```yaml +services: + proxy: + image: traefik:v3.6.2 + command: --providers.docker + ports: + - 80:80 + volumes: + - /var/run/docker.sock:/var/run/docker.sock +``` + +{{< /tab >}} +{{< /tabs >}} Note that this is essentially the same configuration as used earlier, but now in a Compose syntax. 2. The client service has the following configuration, which will start the container and provide it with the labels to receive requests at localhost. - ```yaml {hl_lines=[7,8]} - services: - # … - client: - image: nginx:alpine - volumes: - - "./client:/usr/share/nginx/html" - labels: - traefik.http.routers.client.rule: "Host(`localhost`)" - ``` +{{< tabs >}} +{{< tab name="Using Docker Hardened Images" >}} + +If your organization mirrors the [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx), +you can use it as your base image as shown below: + +```yaml +services: + # … + client: + image: /dhi-nginx:1.29.3-alpine3.21 + volumes: + - "./client:/usr/share/nginx/html" + labels: + traefik.http.routers.client.rule: "Host(`localhost`)" +``` + +{{< /tab >}} +{{< tab name="Using the official image" >}} + +```yaml +services: + # … + client: + image: nginx:1.29.3-alpine3.22 + volumes: + - "./client:/usr/share/nginx/html" + labels: + traefik.http.routers.client.rule: "Host(`localhost`)" +``` + +{{< /tab >}} +{{< /tabs >}} 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. @@ -176,6 +273,26 @@ With this file, the only change is to the Compose configuration for Traefik. The 1. The configuration file is mounted into the Traefik container (the exact destination path is up to you) 2. The `command` is updated to add the file provider and point to the location of the configuration file +{{< tabs >}} +{{< tab name="Using DHI image" >}} + +```yaml +services: + proxy: + image: /dhi-traefik:3.6.2 + command: --providers.docker --providers.file.filename=/config/traefik-config.yaml --api.insecure + ports: + - 80:80 + - 8080:8080 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ./dev/traefik-config.yaml:/config/traefik-config.yaml +``` + +{{< /tab >}} + +{{< tab name="Using official image" >}} + ```yaml services: proxy: @@ -189,6 +306,9 @@ services: - ./dev/traefik-config.yaml:/config/traefik-config.yaml ``` +{{< /tab >}} +{{< /tabs >}} + ### Starting the example app To run the example app that forwards requests from Traefik to native-running apps, use the following steps: From 83ae4b190e075cc0ca76e865b24a2486b2d6bd95 Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari <116190942+jarqvi@users.noreply.github.com> Date: Mon, 24 Nov 2025 20:46:08 +0000 Subject: [PATCH 02/16] fix: typo --- content/guides/traefik.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/guides/traefik.md b/content/guides/traefik.md index 5cd29ccc35d3..34af8f4f6ff9 100644 --- a/content/guides/traefik.md +++ b/content/guides/traefik.md @@ -47,7 +47,7 @@ Let’s do a quick demo of starting Traefik and then configuring two additional $ docker network create traefik-demo ``` -2. Start a Traefik container using one of the following methods. +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. {{< tabs >}} {{< tab name="Using Docker Hardened Images" >}} From 53e41109e0d1a41934f3a3f3cc5527d40e10fb91 Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari <116190942+jarqvi@users.noreply.github.com> Date: Mon, 24 Nov 2025 21:29:46 +0000 Subject: [PATCH 03/16] fix: validate --- content/guides/traefik.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/guides/traefik.md b/content/guides/traefik.md index 34af8f4f6ff9..e1b4e73e22ee 100644 --- a/content/guides/traefik.md +++ b/content/guides/traefik.md @@ -91,7 +91,7 @@ $ docker run -d --network=traefik-demo \ {{< tab name="Using Docker Hardened Images" >}} If your organization uses an [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx), -you can use the mirrored image name below. For example: +you can use the mirrored image name following. For example: ```console $ docker run -d --network=traefik-demo \ @@ -102,7 +102,7 @@ $ docker run -d --network=traefik-demo \ {{< /tab >}} {{< tab name="Using the official image" >}} -You can also run the official NGINX image as follows: +You can also run the official Nginx image as follows: ```console $ docker run -d --network=traefik-demo \ @@ -110,7 +110,7 @@ $ docker run -d --network=traefik-demo \ nginx:1.29.3 ``` -{{< /tab >}} +{{< /tab >}}g {{< /tabs >}} 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). @@ -176,7 +176,7 @@ services: {{< tab name="Using Docker Hardened Images" >}} If your organization mirrors the [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx), -you can use it as your base image as shown below: +you can use it as your base image as shown following: ```yaml services: From 399839f76b86f64adf8a43b86e738ab2913bcce1 Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari <116190942+jarqvi@users.noreply.github.com> Date: Mon, 24 Nov 2025 21:33:35 +0000 Subject: [PATCH 04/16] fix: lint --- content/guides/traefik.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/content/guides/traefik.md b/content/guides/traefik.md index e1b4e73e22ee..40eeabbb57f7 100644 --- a/content/guides/traefik.md +++ b/content/guides/traefik.md @@ -41,6 +41,8 @@ While there are [many Traefik-monitored labels](https://doc.traefik.io/traefik/r Let’s do a quick demo of starting Traefik and then configuring two additional containers to be accessible using different hostnames. + + 1. In order for two containers to be able to communicate with each other, they need to be on the same network. Create a network named `traefik-demo` using the `docker network create` command: ```console @@ -123,6 +125,8 @@ $ docker run -d --network=traefik-demo \ Once the container starts, open your browser to http://welcome.localhost. You should see a “Welcome to Docker” website. + + ## Using Traefik in development Now that you’ve experienced Traefik, it’s time to try using it in a development environment. In this example, you will use a sample application that has a split frontend and backend. This app stack has the following configuration: @@ -135,6 +139,8 @@ Now that you’ve experienced Traefik, it’s time to try using it in a developm The application can be accessed on GitHub at [dockersamples/easy-http-routing-with-traefik](https://github.com/dockersamples/easy-http-routing-with-traefik). + + 1. In the `compose.yaml` file, Traefik is using the following configuration: {{< tabs >}} @@ -237,6 +243,8 @@ services: 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. + + ## Sending traffic to non-containerized workloads In some situations, you may want to forward requests to applications not running in containers. In the following architecture diagram, the same application from before is used, but the API and React apps are now running natively on the host machine. @@ -270,6 +278,8 @@ This configuration indicates that requests that for `localhost/api` will be forw With this file, the only change is to the Compose configuration for Traefik. There are specifically two things that have changed: + + 1. The configuration file is mounted into the Traefik container (the exact destination path is up to you) 2. The `command` is updated to add the file provider and point to the location of the configuration file @@ -309,6 +319,8 @@ services: {{< /tab >}} {{< /tabs >}} + + ### Starting the example app To run the example app that forwards requests from Traefik to native-running apps, use the following steps: From 83778d142394633b68ab0d6a2026813e2beee1bb Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari <116190942+jarqvi@users.noreply.github.com> Date: Tue, 25 Nov 2025 17:47:35 +0000 Subject: [PATCH 05/16] fix: typo --- content/guides/traefik.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/guides/traefik.md b/content/guides/traefik.md index 40eeabbb57f7..ae67f338b066 100644 --- a/content/guides/traefik.md +++ b/content/guides/traefik.md @@ -112,7 +112,7 @@ $ docker run -d --network=traefik-demo \ nginx:1.29.3 ``` -{{< /tab >}}g +{{< /tab >}} {{< /tabs >}} 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). From 3d50e47529cca662a704da23ad891f78573e435c Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari Date: Sun, 28 Dec 2025 11:33:11 +0330 Subject: [PATCH 06/16] chore: improve dhi guide --- content/guides/traefik.md | 40 ++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/content/guides/traefik.md b/content/guides/traefik.md index ae67f338b066..72bcd5ffcf0b 100644 --- a/content/guides/traefik.md +++ b/content/guides/traefik.md @@ -54,12 +54,15 @@ Let’s do a quick demo of starting Traefik and then configuring two additional {{< tabs >}} {{< tab name="Using Docker Hardened Images" >}} -Docker Hardened Images (DHI) for Traefik are available on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/traefik). -Before you can use a DHI image, you must mirror it into your organization’s namespace. -Follow the [DHI quickstart](/dhi/get-started/) to create a mirrored repository. +Docker Hardened Images (DHI) for Traefik are available on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/traefik). +If you haven't authenticated yet, first run: + +```bash +docker login dhi.io +``` For example — use: -`FROM /dhi-traefik:` +`FROM dhi.io/traefik:` Then start a container using the Hardened image: @@ -67,7 +70,7 @@ Then start a container using the Hardened image: $ docker run -d --network=traefik-demo \ -p 80:80 \ -v /var/run/docker.sock:/var/run/docker.sock \ - /dhi-traefik:3.6.2 \ + dhi.io/traefik:3.6.2 \ --providers.docker ``` @@ -92,13 +95,17 @@ $ docker run -d --network=traefik-demo \ {{< tabs >}} {{< tab name="Using Docker Hardened Images" >}} -If your organization uses an [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx), -you can use the mirrored image name following. For example: +Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). +If you haven't authenticated yet, first run: + +```bash +docker login dhi.io +``` ```console $ docker run -d --network=traefik-demo \ --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ - /dhi-nginx:1.29.3 + dhi.io/nginx:1.29.3 ``` {{< /tab >}} @@ -149,7 +156,7 @@ The application can be accessed on GitHub at [dockersamples/easy-http-routing-wi ```yaml services: proxy: - image: /dhi-traefik:3.6.2 + image: dhi.io/traefik:3.6.2 command: --providers.docker ports: - 80:80 @@ -181,14 +188,21 @@ services: {{< tabs >}} {{< tab name="Using Docker Hardened Images" >}} -If your organization mirrors the [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx), -you can use it as your base image as shown following: +Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). + +If you haven't authenticated yet, first run: + +```bash +docker login dhi.io +``` + +You can use it as your base image as shown following: ```yaml services: # … client: - image: /dhi-nginx:1.29.3-alpine3.21 + image: dhi.io/nginx:1.29.3-alpine3.21 volumes: - "./client:/usr/share/nginx/html" labels: @@ -289,7 +303,7 @@ With this file, the only change is to the Compose configuration for Traefik. The ```yaml services: proxy: - image: /dhi-traefik:3.6.2 + image: dhi.io/traefik:3.6.2 command: --providers.docker --providers.file.filename=/config/traefik-config.yaml --api.insecure ports: - 80:80 From acd0166bf5134a957eb926aa2088a7d70915b611 Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari Date: Fri, 13 Feb 2026 18:01:00 +0330 Subject: [PATCH 07/16] fix: format Signed-off-by: MohammadHasan Akbari --- content/guides/traefik.md | 353 ++++++++++++++++++-------------------- 1 file changed, 169 insertions(+), 184 deletions(-) diff --git a/content/guides/traefik.md b/content/guides/traefik.md index 72bcd5ffcf0b..c794b2954065 100644 --- a/content/guides/traefik.md +++ b/content/guides/traefik.md @@ -41,8 +41,6 @@ While there are [many Traefik-monitored labels](https://doc.traefik.io/traefik/r Let’s do a quick demo of starting Traefik and then configuring two additional containers to be accessible using different hostnames. - - 1. In order for two containers to be able to communicate with each other, they need to be on the same network. Create a network named `traefik-demo` using the `docker network create` command: ```console @@ -51,76 +49,73 @@ Let’s do a quick demo of starting Traefik and then configuring two additional 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. -{{< tabs >}} -{{< tab name="Using Docker Hardened Images" >}} - -Docker Hardened Images (DHI) for Traefik are available on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/traefik). -If you haven't authenticated yet, first run: + {{< tabs >}} + {{< tab name="Using Docker Hardened Images" >}} -```bash -docker login dhi.io -``` + Docker Hardened Images (DHI) for Traefik are available on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/traefik). + If you haven't authenticated yet, first run: -For example — use: -`FROM dhi.io/traefik:` + ```bash + docker login dhi.io + ``` -Then start a container using the Hardened image: + Then start a container using the Hardened image: -```console -$ docker run -d --network=traefik-demo \ - -p 80:80 \ - -v /var/run/docker.sock:/var/run/docker.sock \ - dhi.io/traefik:3.6.2 \ - --providers.docker -``` + ```console + $ docker run -d --network=traefik-demo \ + -p 80:80 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + dhi.io/traefik:3.6.2 \ + --providers.docker + ``` -{{< /tab >}} -{{< tab name="Using the official image" >}} + {{< /tab >}} + {{< tab name="Using the official image" >}} -You can also use the official image from Docker Hub: + You can also use the official image from Docker Hub: -```console -$ docker run -d --network=traefik-demo \ - -p 80:80 \ - -v /var/run/docker.sock:/var/run/docker.sock \ - traefik:v3.6.2 \ - --providers.docker -``` + ```console + $ docker run -d --network=traefik-demo \ + -p 80:80 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + traefik:v3.6.2 \ + --providers.docker + ``` -{{< /tab >}} -{{< /tabs >}} + {{< /tab >}} + {{< /tabs >}} 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. -{{< tabs >}} -{{< tab name="Using Docker Hardened Images" >}} + {{< tabs >}} + {{< tab name="Using Docker Hardened Images" >}} -Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). -If you haven't authenticated yet, first run: + Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). + If you haven't authenticated yet, first run: -```bash -docker login dhi.io -``` + ```bash + docker login dhi.io + ``` -```console -$ docker run -d --network=traefik-demo \ - --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ - dhi.io/nginx:1.29.3 -``` + ```console + $ docker run -d --network=traefik-demo \ + --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ + dhi.io/nginx:1.29.3 + ``` -{{< /tab >}} -{{< tab name="Using the official image" >}} + {{< /tab >}} + {{< tab name="Using the official image" >}} -You can also run the official Nginx image as follows: + You can also run the official Nginx image as follows: -```console -$ docker run -d --network=traefik-demo \ - --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ - nginx:1.29.3 -``` + ```console + $ docker run -d --network=traefik-demo \ + --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ + nginx:1.29.3 + ``` -{{< /tab >}} -{{< /tabs >}} + {{< /tab >}} + {{< /tabs >}} 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). @@ -132,8 +127,6 @@ $ docker run -d --network=traefik-demo \ Once the container starts, open your browser to http://welcome.localhost. You should see a “Welcome to Docker” website. - - ## Using Traefik in development Now that you’ve experienced Traefik, it’s time to try using it in a development environment. In this example, you will use a sample application that has a split frontend and backend. This app stack has the following configuration: @@ -146,118 +139,114 @@ Now that you’ve experienced Traefik, it’s time to try using it in a developm The application can be accessed on GitHub at [dockersamples/easy-http-routing-with-traefik](https://github.com/dockersamples/easy-http-routing-with-traefik). - - 1. In the `compose.yaml` file, Traefik is using the following configuration: -{{< tabs >}} -{{< tab name="Using DHI image" >}} + {{< tabs >}} + {{< tab name="Using DHI image" >}} -```yaml -services: - proxy: - image: dhi.io/traefik:3.6.2 - command: --providers.docker - ports: - - 80:80 - volumes: - - /var/run/docker.sock:/var/run/docker.sock -``` - -{{< /tab >}} -{{< tab name="Using official image" >}} - -```yaml -services: - proxy: - image: traefik:v3.6.2 - command: --providers.docker - ports: - - 80:80 - volumes: - - /var/run/docker.sock:/var/run/docker.sock -``` + ```yaml + services: + proxy: + image: dhi.io/traefik:3.6.2 + command: --providers.docker + ports: + - 80:80 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + ``` + + {{< /tab >}} + {{< tab name="Using official image" >}} + + ```yaml + services: + proxy: + image: traefik:v3.6.2 + command: --providers.docker + ports: + - 80:80 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + ``` -{{< /tab >}} -{{< /tabs >}} + {{< /tab >}} + {{< /tabs >}} - Note that this is essentially the same configuration as used earlier, but now in a Compose syntax. + Note that this is essentially the same configuration as used earlier, but now in a Compose syntax. 2. The client service has the following configuration, which will start the container and provide it with the labels to receive requests at localhost. -{{< tabs >}} -{{< tab name="Using Docker Hardened Images" >}} + {{< tabs >}} + {{< tab name="Using Docker Hardened Images" >}} -Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). + Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). -If you haven't authenticated yet, first run: + If you haven't authenticated yet, first run: -```bash -docker login dhi.io -``` - -You can use it as your base image as shown following: - -```yaml -services: - # … - client: - image: dhi.io/nginx:1.29.3-alpine3.21 - volumes: - - "./client:/usr/share/nginx/html" - labels: - traefik.http.routers.client.rule: "Host(`localhost`)" -``` + ```bash + docker login dhi.io + ``` -{{< /tab >}} -{{< tab name="Using the official image" >}} + You can use it as your base image as shown following: -```yaml -services: - # … - client: - image: nginx:1.29.3-alpine3.22 - volumes: - - "./client:/usr/share/nginx/html" - labels: - traefik.http.routers.client.rule: "Host(`localhost`)" -``` - -{{< /tab >}} -{{< /tabs >}} + ```yaml + services: + # … + client: + image: dhi.io/nginx:1.29.3-alpine3.21 + volumes: + - "./client:/usr/share/nginx/html" + labels: + traefik.http.routers.client.rule: "Host(`localhost`)" + ``` + + {{< /tab >}} + {{< tab name="Using the official image" >}} + + ```yaml + services: + # … + client: + image: nginx:1.29.3-alpine3.22 + volumes: + - "./client:/usr/share/nginx/html" + labels: + traefik.http.routers.client.rule: "Host(`localhost`)" + ``` + + {{< /tab >}} + {{< /tabs >}} 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. - ```yaml {hl_lines=[7,8]} - services: - # … - api: - build: ./dev/api - volumes: - - "./api:/var/www/html/api" - labels: - traefik.http.routers.api.rule: "Host(`localhost`) && PathPrefix(`/api`)" - ``` + ```yaml {hl_lines=[7,8]} + services: + # … + api: + build: ./dev/api + volumes: + - "./api:/var/www/html/api" + labels: + traefik.http.routers.api.rule: "Host(`localhost`) && PathPrefix(`/api`)" + ``` 4. And finally, the `phpmyadmin` service is configured to receive requests for the hostname “db.localhost”. The service also has environment variables defined to automatically log in, making it a little easier to get into the app. - ```yaml {hl_lines=[5,6]} - services: - # … - phpmyadmin: - image: phpmyadmin:5.2.1 - labels: - traefik.http.routers.db.rule: "Host(`db.localhost`)" - environment: - PMA_USER: root - PMA_PASSWORD: password - ``` + ```yaml {hl_lines=[5,6]} + services: + # … + phpmyadmin: + image: phpmyadmin:5.2.1 + labels: + traefik.http.routers.db.rule: "Host(`db.localhost`)" + environment: + PMA_USER: root + PMA_PASSWORD: password + ``` 5. Before starting the stack, stop the Nginx container if it is still running. -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. - - + 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. ## Sending traffic to non-containerized workloads @@ -292,48 +281,44 @@ This configuration indicates that requests that for `localhost/api` will be forw With this file, the only change is to the Compose configuration for Traefik. There are specifically two things that have changed: - - 1. The configuration file is mounted into the Traefik container (the exact destination path is up to you) 2. The `command` is updated to add the file provider and point to the location of the configuration file -{{< tabs >}} -{{< tab name="Using DHI image" >}} + {{< tabs >}} + {{< tab name="Using DHI image" >}} -```yaml -services: - proxy: - image: dhi.io/traefik:3.6.2 - command: --providers.docker --providers.file.filename=/config/traefik-config.yaml --api.insecure - ports: - - 80:80 - - 8080:8080 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - - ./dev/traefik-config.yaml:/config/traefik-config.yaml -``` - -{{< /tab >}} - -{{< tab name="Using official image" >}} - -```yaml -services: - proxy: - image: traefik:v3.6.2 - command: --providers.docker --providers.file.filename=/config/traefik-config.yaml --api.insecure - ports: - - 80:80 - - 8080:8080 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - - ./dev/traefik-config.yaml:/config/traefik-config.yaml -``` - -{{< /tab >}} -{{< /tabs >}} - - + ```yaml + services: + proxy: + image: dhi.io/traefik:3.6.2 + command: --providers.docker --providers.file.filename=/config/traefik-config.yaml --api.insecure + ports: + - 80:80 + - 8080:8080 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ./dev/traefik-config.yaml:/config/traefik-config.yaml + ``` + + {{< /tab >}} + + {{< tab name="Using official image" >}} + + ```yaml + services: + proxy: + image: traefik:v3.6.2 + command: --providers.docker --providers.file.filename=/config/traefik-config.yaml --api.insecure + ports: + - 80:80 + - 8080:8080 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ./dev/traefik-config.yaml:/config/traefik-config.yaml + ``` + + {{< /tab >}} + {{< /tabs >}} ### Starting the example app From a2b6db8525fd5d94bd7462bb814fc653b2970159 Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari Date: Fri, 13 Feb 2026 18:10:30 +0330 Subject: [PATCH 08/16] fix: lint Signed-off-by: MohammadHasan Akbari --- content/guides/traefik.md | 124 +++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/content/guides/traefik.md b/content/guides/traefik.md index c794b2954065..88045c9c36dc 100644 --- a/content/guides/traefik.md +++ b/content/guides/traefik.md @@ -176,77 +176,77 @@ The application can be accessed on GitHub at [dockersamples/easy-http-routing-wi 2. The client service has the following configuration, which will start the container and provide it with the labels to receive requests at localhost. - {{< tabs >}} - {{< tab name="Using Docker Hardened Images" >}} - - Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). - - If you haven't authenticated yet, first run: - - ```bash - docker login dhi.io - ``` - - You can use it as your base image as shown following: - - ```yaml - services: - # … - client: - image: dhi.io/nginx:1.29.3-alpine3.21 - volumes: - - "./client:/usr/share/nginx/html" - labels: - traefik.http.routers.client.rule: "Host(`localhost`)" - ``` - - {{< /tab >}} - {{< tab name="Using the official image" >}} - - ```yaml - services: - # … - client: - image: nginx:1.29.3-alpine3.22 - volumes: - - "./client:/usr/share/nginx/html" - labels: - traefik.http.routers.client.rule: "Host(`localhost`)" - ``` - - {{< /tab >}} - {{< /tabs >}} + {{< tabs >}} + {{< tab name="Using Docker Hardened Images" >}} + + Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). + + If you haven't authenticated yet, first run: + + ```bash + docker login dhi.io + ``` + + You can use it as your base image as shown following: + + ```yaml + services: + # … + client: + image: dhi.io/nginx:1.29.3-alpine3.21 + volumes: + - "./client:/usr/share/nginx/html" + labels: + traefik.http.routers.client.rule: "Host(`localhost`)" + ``` + + {{< /tab >}} + {{< tab name="Using the official image" >}} + + ```yaml + services: + # … + client: + image: nginx:1.29.3-alpine3.22 + volumes: + - "./client:/usr/share/nginx/html" + labels: + traefik.http.routers.client.rule: "Host(`localhost`)" + ``` + + {{< /tab >}} + {{< /tabs >}} 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. - ```yaml {hl_lines=[7,8]} - services: - # … - api: - build: ./dev/api - volumes: - - "./api:/var/www/html/api" - labels: - traefik.http.routers.api.rule: "Host(`localhost`) && PathPrefix(`/api`)" - ``` + ```yaml {hl_lines=[7,8]} + services: + # … + api: + build: ./dev/api + volumes: + - "./api:/var/www/html/api" + labels: + traefik.http.routers.api.rule: "Host(`localhost`) && PathPrefix(`/api`)" + ``` 4. And finally, the `phpmyadmin` service is configured to receive requests for the hostname “db.localhost”. The service also has environment variables defined to automatically log in, making it a little easier to get into the app. - ```yaml {hl_lines=[5,6]} - services: - # … - phpmyadmin: - image: phpmyadmin:5.2.1 - labels: - traefik.http.routers.db.rule: "Host(`db.localhost`)" - environment: - PMA_USER: root - PMA_PASSWORD: password - ``` + ```yaml {hl_lines=[5,6]} + services: + # … + phpmyadmin: + image: phpmyadmin:5.2.1 + labels: + traefik.http.routers.db.rule: "Host(`db.localhost`)" + environment: + PMA_USER: root + PMA_PASSWORD: password + ``` 5. Before starting the stack, stop the Nginx container if it is still running. - 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. + 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. ## Sending traffic to non-containerized workloads From b0930e13939100d4ed34d39001e89c541b084766 Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari Date: Fri, 13 Feb 2026 18:14:36 +0330 Subject: [PATCH 09/16] fix: lint again:) Signed-off-by: MohammadHasan Akbari --- content/guides/traefik.md | 108 +++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/content/guides/traefik.md b/content/guides/traefik.md index 88045c9c36dc..e343701dd3f3 100644 --- a/content/guides/traefik.md +++ b/content/guides/traefik.md @@ -87,45 +87,45 @@ Let’s do a quick demo of starting Traefik and then configuring two additional 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. - {{< tabs >}} - {{< tab name="Using Docker Hardened Images" >}} + {{< tabs >}} + {{< tab name="Using Docker Hardened Images" >}} - Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). - If you haven't authenticated yet, first run: + Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). + If you haven't authenticated yet, first run: - ```bash - docker login dhi.io - ``` + ```bash + docker login dhi.io + ``` - ```console - $ docker run -d --network=traefik-demo \ - --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ - dhi.io/nginx:1.29.3 - ``` + ```console + $ docker run -d --network=traefik-demo \ + --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ + dhi.io/nginx:1.29.3 + ``` - {{< /tab >}} - {{< tab name="Using the official image" >}} + {{< /tab >}} + {{< tab name="Using the official image" >}} - You can also run the official Nginx image as follows: + You can also run the official Nginx image as follows: - ```console - $ docker run -d --network=traefik-demo \ - --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ - nginx:1.29.3 - ``` + ```console + $ docker run -d --network=traefik-demo \ + --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ + nginx:1.29.3 + ``` - {{< /tab >}} - {{< /tabs >}} + {{< /tab >}} + {{< /tabs >}} - 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). + 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). 4. Start a second application that will use a different hostname. - ```console - $ docker run -d --network=traefik-demo --label 'traefik.http.routers.welcome.rule=Host(`welcome.localhost`)' docker/welcome-to-docker - ``` + ```console + $ docker run -d --network=traefik-demo --label 'traefik.http.routers.welcome.rule=Host(`welcome.localhost`)' docker/welcome-to-docker + ``` - Once the container starts, open your browser to http://welcome.localhost. You should see a “Welcome to Docker” website. + Once the container starts, open your browser to http://welcome.localhost. You should see a “Welcome to Docker” website. ## Using Traefik in development @@ -141,38 +141,38 @@ The application can be accessed on GitHub at [dockersamples/easy-http-routing-wi 1. In the `compose.yaml` file, Traefik is using the following configuration: - {{< tabs >}} - {{< tab name="Using DHI image" >}} + {{< tabs >}} + {{< tab name="Using DHI image" >}} - ```yaml - services: - proxy: - image: dhi.io/traefik:3.6.2 - command: --providers.docker - ports: - - 80:80 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - ``` + ```yaml + services: + proxy: + image: dhi.io/traefik:3.6.2 + command: --providers.docker + ports: + - 80:80 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + ``` - {{< /tab >}} - {{< tab name="Using official image" >}} + {{< /tab >}} + {{< tab name="Using official image" >}} - ```yaml - services: - proxy: - image: traefik:v3.6.2 - command: --providers.docker - ports: - - 80:80 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - ``` + ```yaml + services: + proxy: + image: traefik:v3.6.2 + command: --providers.docker + ports: + - 80:80 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + ``` - {{< /tab >}} - {{< /tabs >}} + {{< /tab >}} + {{< /tabs >}} - Note that this is essentially the same configuration as used earlier, but now in a Compose syntax. + Note that this is essentially the same configuration as used earlier, but now in a Compose syntax. 2. The client service has the following configuration, which will start the container and provide it with the labels to receive requests at localhost. From 22a5380fff2c20a51f6237acc5a69bcdb40a325a Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari Date: Fri, 13 Feb 2026 18:17:06 +0330 Subject: [PATCH 10/16] fix: typo Signed-off-by: MohammadHasan Akbari --- content/guides/traefik.md | 54 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/content/guides/traefik.md b/content/guides/traefik.md index e343701dd3f3..57e2b6ed3927 100644 --- a/content/guides/traefik.md +++ b/content/guides/traefik.md @@ -49,41 +49,41 @@ Let’s do a quick demo of starting Traefik and then configuring two additional 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. - {{< tabs >}} - {{< tab name="Using Docker Hardened Images" >}} + {{< tabs >}} + {{< tab name="Using Docker Hardened Images" >}} - Docker Hardened Images (DHI) for Traefik are available on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/traefik). - If you haven't authenticated yet, first run: + Docker Hardened Images (DHI) for Traefik are available on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/traefik). + If you haven't authenticated yet, first run: - ```bash - docker login dhi.io - ``` + ```bash + docker login dhi.io + ``` - Then start a container using the Hardened image: + Then start a container using the Hardened image: - ```console - $ docker run -d --network=traefik-demo \ - -p 80:80 \ - -v /var/run/docker.sock:/var/run/docker.sock \ - dhi.io/traefik:3.6.2 \ - --providers.docker - ``` + ```console + $ docker run -d --network=traefik-demo \ + -p 80:80 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + dhi.io/traefik:3.6.2 \ + --providers.docker + ``` - {{< /tab >}} - {{< tab name="Using the official image" >}} + {{< /tab >}} + {{< tab name="Using the official image" >}} - You can also use the official image from Docker Hub: + You can also use the official image from Docker Hub: - ```console - $ docker run -d --network=traefik-demo \ - -p 80:80 \ - -v /var/run/docker.sock:/var/run/docker.sock \ - traefik:v3.6.2 \ - --providers.docker - ``` + ```console + $ docker run -d --network=traefik-demo \ + -p 80:80 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + traefik:v3.6.2 \ + --providers.docker + ``` - {{< /tab >}} - {{< /tabs >}} + {{< /tab >}} + {{< /tabs >}} 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. From 5afe8fce5c49115bb36a93af3e138f320c26feb8 Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari Date: Fri, 13 Feb 2026 18:29:34 +0330 Subject: [PATCH 11/16] fix: tabs Signed-off-by: MohammadHasan Akbari --- content/guides/traefik.md | 166 +++++++++++++++++++------------------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/content/guides/traefik.md b/content/guides/traefik.md index 57e2b6ed3927..cede64c9b0de 100644 --- a/content/guides/traefik.md +++ b/content/guides/traefik.md @@ -52,35 +52,35 @@ Let’s do a quick demo of starting Traefik and then configuring two additional {{< tabs >}} {{< tab name="Using Docker Hardened Images" >}} - Docker Hardened Images (DHI) for Traefik are available on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/traefik). - If you haven't authenticated yet, first run: + Docker Hardened Images (DHI) for Traefik are available on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/traefik). + If you haven't authenticated yet, first run: - ```bash - docker login dhi.io - ``` + ```bash + docker login dhi.io + ``` - Then start a container using the Hardened image: + Then start a container using the Hardened image: - ```console - $ docker run -d --network=traefik-demo \ - -p 80:80 \ - -v /var/run/docker.sock:/var/run/docker.sock \ - dhi.io/traefik:3.6.2 \ - --providers.docker - ``` + ```console + $ docker run -d --network=traefik-demo \ + -p 80:80 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + dhi.io/traefik:3.6.2 \ + --providers.docker + ``` {{< /tab >}} {{< tab name="Using the official image" >}} - You can also use the official image from Docker Hub: + You can also use the official image from Docker Hub: - ```console - $ docker run -d --network=traefik-demo \ - -p 80:80 \ - -v /var/run/docker.sock:/var/run/docker.sock \ - traefik:v3.6.2 \ - --providers.docker - ``` + ```console + $ docker run -d --network=traefik-demo \ + -p 80:80 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + traefik:v3.6.2 \ + --providers.docker + ``` {{< /tab >}} {{< /tabs >}} @@ -90,29 +90,29 @@ Let’s do a quick demo of starting Traefik and then configuring two additional {{< tabs >}} {{< tab name="Using Docker Hardened Images" >}} - Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). - If you haven't authenticated yet, first run: + Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). + If you haven't authenticated yet, first run: - ```bash - docker login dhi.io - ``` + ```bash + docker login dhi.io + ``` - ```console - $ docker run -d --network=traefik-demo \ - --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ - dhi.io/nginx:1.29.3 - ``` + ```console + $ docker run -d --network=traefik-demo \ + --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ + dhi.io/nginx:1.29.3 + ``` {{< /tab >}} {{< tab name="Using the official image" >}} - You can also run the official Nginx image as follows: + You can also run the official Nginx image as follows: - ```console - $ docker run -d --network=traefik-demo \ - --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ - nginx:1.29.3 - ``` + ```console + $ docker run -d --network=traefik-demo \ + --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ + nginx:1.29.3 + ``` {{< /tab >}} {{< /tabs >}} @@ -144,30 +144,30 @@ The application can be accessed on GitHub at [dockersamples/easy-http-routing-wi {{< tabs >}} {{< tab name="Using DHI image" >}} - ```yaml - services: - proxy: - image: dhi.io/traefik:3.6.2 - command: --providers.docker - ports: - - 80:80 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - ``` + ```yaml + services: + proxy: + image: dhi.io/traefik:3.6.2 + command: --providers.docker + ports: + - 80:80 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + ``` {{< /tab >}} {{< tab name="Using official image" >}} - ```yaml - services: - proxy: - image: traefik:v3.6.2 - command: --providers.docker - ports: - - 80:80 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - ``` + ```yaml + services: + proxy: + image: traefik:v3.6.2 + command: --providers.docker + ports: + - 80:80 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + ``` {{< /tab >}} {{< /tabs >}} @@ -179,40 +179,40 @@ The application can be accessed on GitHub at [dockersamples/easy-http-routing-wi {{< tabs >}} {{< tab name="Using Docker Hardened Images" >}} - Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). + Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). - If you haven't authenticated yet, first run: + If you haven't authenticated yet, first run: - ```bash - docker login dhi.io - ``` + ```bash + docker login dhi.io + ``` - You can use it as your base image as shown following: + You can use it as your base image as shown following: - ```yaml - services: - # … - client: - image: dhi.io/nginx:1.29.3-alpine3.21 - volumes: - - "./client:/usr/share/nginx/html" - labels: - traefik.http.routers.client.rule: "Host(`localhost`)" - ``` + ```yaml + services: + # … + client: + image: dhi.io/nginx:1.29.3-alpine3.21 + volumes: + - "./client:/usr/share/nginx/html" + labels: + traefik.http.routers.client.rule: "Host(`localhost`)" + ``` {{< /tab >}} {{< tab name="Using the official image" >}} - ```yaml - services: - # … - client: - image: nginx:1.29.3-alpine3.22 - volumes: - - "./client:/usr/share/nginx/html" - labels: - traefik.http.routers.client.rule: "Host(`localhost`)" - ``` + ```yaml + services: + # … + client: + image: nginx:1.29.3-alpine3.22 + volumes: + - "./client:/usr/share/nginx/html" + labels: + traefik.http.routers.client.rule: "Host(`localhost`)" + ``` {{< /tab >}} {{< /tabs >}} From 6571e56e2b7ab47d52c6586eb68a22728fdf85b9 Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari Date: Fri, 13 Feb 2026 18:45:13 +0330 Subject: [PATCH 12/16] fix: tabs again:) Signed-off-by: MohammadHasan Akbari --- content/guides/traefik.md | 290 +++++++++++++++++++------------------- 1 file changed, 147 insertions(+), 143 deletions(-) diff --git a/content/guides/traefik.md b/content/guides/traefik.md index cede64c9b0de..51636384fa01 100644 --- a/content/guides/traefik.md +++ b/content/guides/traefik.md @@ -43,89 +43,91 @@ Let’s do a quick demo of starting Traefik and then configuring two additional 1. In order for two containers to be able to communicate with each other, they need to be on the same network. Create a network named `traefik-demo` using the `docker network create` command: - ```console - $ docker network create traefik-demo - ``` + ```console + $ docker network create traefik-demo + ``` 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. - {{< tabs >}} - {{< tab name="Using Docker Hardened Images" >}} + {{< tabs >}} + {{< tab name="Using Docker Hardened Images" >}} - Docker Hardened Images (DHI) for Traefik are available on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/traefik). - If you haven't authenticated yet, first run: + Docker Hardened Images (DHI) for Traefik are available on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/traefik). + If you haven't authenticated yet, first run: - ```bash - docker login dhi.io - ``` + ```bash + docker login dhi.io + ``` - Then start a container using the Hardened image: + Then start a container using the Hardened image: - ```console - $ docker run -d --network=traefik-demo \ - -p 80:80 \ - -v /var/run/docker.sock:/var/run/docker.sock \ - dhi.io/traefik:3.6.2 \ - --providers.docker - ``` + ```console + $ docker run -d --network=traefik-demo \ + -p 80:80 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + dhi.io/traefik:3.6.2 \ + --providers.docker + ``` + + {{< /tab >}} - {{< /tab >}} - {{< tab name="Using the official image" >}} + {{< tab name="Using the official image" >}} - You can also use the official image from Docker Hub: + You can also use the official image from Docker Hub: - ```console - $ docker run -d --network=traefik-demo \ - -p 80:80 \ - -v /var/run/docker.sock:/var/run/docker.sock \ - traefik:v3.6.2 \ - --providers.docker - ``` + ```console + $ docker run -d --network=traefik-demo \ + -p 80:80 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + traefik:v3.6.2 \ + --providers.docker + ``` - {{< /tab >}} - {{< /tabs >}} + {{< /tab >}} + {{< /tabs >}} 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. - {{< tabs >}} - {{< tab name="Using Docker Hardened Images" >}} + {{< tabs >}} + {{< tab name="Using Docker Hardened Images" >}} - Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). - If you haven't authenticated yet, first run: + Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). + If you haven't authenticated yet, first run: - ```bash - docker login dhi.io - ``` + ```bash + docker login dhi.io + ``` - ```console - $ docker run -d --network=traefik-demo \ - --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ - dhi.io/nginx:1.29.3 - ``` + ```console + $ docker run -d --network=traefik-demo \ + --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ + dhi.io/nginx:1.29.3 + ``` - {{< /tab >}} - {{< tab name="Using the official image" >}} + {{< /tab >}} - You can also run the official Nginx image as follows: + {{< tab name="Using the official image" >}} - ```console - $ docker run -d --network=traefik-demo \ - --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ - nginx:1.29.3 - ``` + You can also run the official Nginx image as follows: - {{< /tab >}} - {{< /tabs >}} + ```console + $ docker run -d --network=traefik-demo \ + --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ + nginx:1.29.3 + ``` - 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). + {{< /tab >}} + {{< /tabs >}} + + 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). 4. Start a second application that will use a different hostname. - ```console - $ docker run -d --network=traefik-demo --label 'traefik.http.routers.welcome.rule=Host(`welcome.localhost`)' docker/welcome-to-docker - ``` + ```console + $ docker run -d --network=traefik-demo --label 'traefik.http.routers.welcome.rule=Host(`welcome.localhost`)' docker/welcome-to-docker + ``` - Once the container starts, open your browser to http://welcome.localhost. You should see a “Welcome to Docker” website. + Once the container starts, open your browser to http://welcome.localhost. You should see a “Welcome to Docker” website. ## Using Traefik in development @@ -141,112 +143,114 @@ The application can be accessed on GitHub at [dockersamples/easy-http-routing-wi 1. In the `compose.yaml` file, Traefik is using the following configuration: - {{< tabs >}} - {{< tab name="Using DHI image" >}} - - ```yaml - services: - proxy: - image: dhi.io/traefik:3.6.2 - command: --providers.docker - ports: - - 80:80 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - ``` - - {{< /tab >}} - {{< tab name="Using official image" >}} - - ```yaml - services: - proxy: - image: traefik:v3.6.2 - command: --providers.docker - ports: - - 80:80 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - ``` - - {{< /tab >}} - {{< /tabs >}} - - Note that this is essentially the same configuration as used earlier, but now in a Compose syntax. + {{< tabs >}} + {{< tab name="Using DHI image" >}} + + ```yaml + services: + proxy: + image: dhi.io/traefik:3.6.2 + command: --providers.docker + ports: + - 80:80 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + ``` + + {{< /tab >}} + + {{< tab name="Using official image" >}} + + ```yaml + services: + proxy: + image: traefik:v3.6.2 + command: --providers.docker + ports: + - 80:80 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + ``` + + {{< /tab >}} + {{< /tabs >}} + + Note that this is essentially the same configuration as used earlier, but now in a Compose syntax. 2. The client service has the following configuration, which will start the container and provide it with the labels to receive requests at localhost. - {{< tabs >}} - {{< tab name="Using Docker Hardened Images" >}} + {{< tabs >}} + {{< tab name="Using Docker Hardened Images" >}} + + Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). - Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). + If you haven't authenticated yet, first run: - If you haven't authenticated yet, first run: + ```bash + docker login dhi.io + ``` - ```bash - docker login dhi.io - ``` + You can use it as your base image as shown following: - You can use it as your base image as shown following: + ```yaml + services: + # … + client: + image: dhi.io/nginx:1.29.3-alpine3.21 + volumes: + - "./client:/usr/share/nginx/html" + labels: + traefik.http.routers.client.rule: "Host(`localhost`)" + ``` - ```yaml - services: - # … - client: - image: dhi.io/nginx:1.29.3-alpine3.21 - volumes: - - "./client:/usr/share/nginx/html" - labels: - traefik.http.routers.client.rule: "Host(`localhost`)" - ``` + {{< /tab >}} - {{< /tab >}} - {{< tab name="Using the official image" >}} + {{< tab name="Using the official image" >}} - ```yaml - services: - # … - client: - image: nginx:1.29.3-alpine3.22 - volumes: - - "./client:/usr/share/nginx/html" - labels: - traefik.http.routers.client.rule: "Host(`localhost`)" - ``` + ```yaml + services: + # … + client: + image: nginx:1.29.3-alpine3.22 + volumes: + - "./client:/usr/share/nginx/html" + labels: + traefik.http.routers.client.rule: "Host(`localhost`)" + ``` - {{< /tab >}} - {{< /tabs >}} + {{< /tab >}} + {{< /tabs >}} 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. - ```yaml {hl_lines=[7,8]} - services: - # … - api: - build: ./dev/api - volumes: - - "./api:/var/www/html/api" - labels: - traefik.http.routers.api.rule: "Host(`localhost`) && PathPrefix(`/api`)" - ``` + ```yaml {hl_lines=[7,8]} + services: + # … + api: + build: ./dev/api + volumes: + - "./api:/var/www/html/api" + labels: + traefik.http.routers.api.rule: "Host(`localhost`) && PathPrefix(`/api`)" + ``` 4. And finally, the `phpmyadmin` service is configured to receive requests for the hostname “db.localhost”. The service also has environment variables defined to automatically log in, making it a little easier to get into the app. - ```yaml {hl_lines=[5,6]} - services: - # … - phpmyadmin: - image: phpmyadmin:5.2.1 - labels: - traefik.http.routers.db.rule: "Host(`db.localhost`)" - environment: - PMA_USER: root - PMA_PASSWORD: password - ``` + ```yaml {hl_lines=[5,6]} + services: + # … + phpmyadmin: + image: phpmyadmin:5.2.1 + labels: + traefik.http.routers.db.rule: "Host(`db.localhost`)" + environment: + PMA_USER: root + PMA_PASSWORD: password + ``` 5. Before starting the stack, stop the Nginx container if it is still running. - 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. + 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. ## Sending traffic to non-containerized workloads From 4cf310e8627c6f30ba7c6851a7dd72ade4220f85 Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari Date: Fri, 13 Feb 2026 18:59:06 +0330 Subject: [PATCH 13/16] fix: typo Signed-off-by: MohammadHasan Akbari --- content/guides/traefik.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/guides/traefik.md b/content/guides/traefik.md index 51636384fa01..1fe60498c8c9 100644 --- a/content/guides/traefik.md +++ b/content/guides/traefik.md @@ -43,9 +43,9 @@ Let’s do a quick demo of starting Traefik and then configuring two additional 1. In order for two containers to be able to communicate with each other, they need to be on the same network. Create a network named `traefik-demo` using the `docker network create` command: - ```console - $ docker network create traefik-demo - ``` + ```console + $ docker network create traefik-demo + ``` 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. @@ -56,7 +56,7 @@ Let’s do a quick demo of starting Traefik and then configuring two additional If you haven't authenticated yet, first run: ```bash - docker login dhi.io + $ docker login dhi.io ``` Then start a container using the Hardened image: @@ -95,7 +95,7 @@ Let’s do a quick demo of starting Traefik and then configuring two additional If you haven't authenticated yet, first run: ```bash - docker login dhi.io + $ docker login dhi.io ``` ```console From 6325c384707a854844fca3a5356049c137595bfa Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari Date: Fri, 13 Feb 2026 19:05:35 +0330 Subject: [PATCH 14/16] fix: step 2 Signed-off-by: MohammadHasan Akbari --- content/guides/traefik.md | 54 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/content/guides/traefik.md b/content/guides/traefik.md index 1fe60498c8c9..e50084e0356b 100644 --- a/content/guides/traefik.md +++ b/content/guides/traefik.md @@ -49,42 +49,42 @@ Let’s do a quick demo of starting Traefik and then configuring two additional 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. - {{< tabs >}} - {{< tab name="Using Docker Hardened Images" >}} + {{< tabs >}} + {{< tab name="Using Docker Hardened Images" >}} - Docker Hardened Images (DHI) for Traefik are available on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/traefik). - If you haven't authenticated yet, first run: + Docker Hardened Images (DHI) for Traefik are available on [Docker Hub](https://hub.docker.com/hardened-images/catalog/dhi/traefik). + If you haven't authenticated yet, first run: - ```bash - $ docker login dhi.io - ``` + ```bash + $ docker login dhi.io + ``` - Then start a container using the Hardened image: + Then start a container using the Hardened image: - ```console - $ docker run -d --network=traefik-demo \ - -p 80:80 \ - -v /var/run/docker.sock:/var/run/docker.sock \ - dhi.io/traefik:3.6.2 \ - --providers.docker - ``` + ```console + $ docker run -d --network=traefik-demo \ + -p 80:80 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + dhi.io/traefik:3.6.2 \ + --providers.docker + ``` - {{< /tab >}} + {{< /tab >}} - {{< tab name="Using the official image" >}} + {{< tab name="Using the official image" >}} - You can also use the official image from Docker Hub: + You can also use the official image from Docker Hub: - ```console - $ docker run -d --network=traefik-demo \ - -p 80:80 \ - -v /var/run/docker.sock:/var/run/docker.sock \ - traefik:v3.6.2 \ - --providers.docker - ``` + ```console + $ docker run -d --network=traefik-demo \ + -p 80:80 \ + -v /var/run/docker.sock:/var/run/docker.sock \ + traefik:v3.6.2 \ + --providers.docker + ``` - {{< /tab >}} - {{< /tabs >}} + {{< /tab >}} + {{< /tabs >}} 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. From 08d81da91edefcfba1b8d5572301f667a2b08468 Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari Date: Fri, 13 Feb 2026 19:08:16 +0330 Subject: [PATCH 15/16] fix: step 3 & 4 Signed-off-by: MohammadHasan Akbari --- content/guides/traefik.md | 54 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/content/guides/traefik.md b/content/guides/traefik.md index e50084e0356b..3058b304041d 100644 --- a/content/guides/traefik.md +++ b/content/guides/traefik.md @@ -88,46 +88,46 @@ Let’s do a quick demo of starting Traefik and then configuring two additional 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. - {{< tabs >}} - {{< tab name="Using Docker Hardened Images" >}} + {{< tabs >}} + {{< tab name="Using Docker Hardened Images" >}} - Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). - If you haven't authenticated yet, first run: + Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). + If you haven't authenticated yet, first run: - ```bash - $ docker login dhi.io - ``` + ```bash + $ docker login dhi.io + ``` - ```console - $ docker run -d --network=traefik-demo \ - --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ - dhi.io/nginx:1.29.3 - ``` + ```console + $ docker run -d --network=traefik-demo \ + --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ + dhi.io/nginx:1.29.3 + ``` - {{< /tab >}} + {{< /tab >}} - {{< tab name="Using the official image" >}} + {{< tab name="Using the official image" >}} - You can also run the official Nginx image as follows: + You can also run the official Nginx image as follows: - ```console - $ docker run -d --network=traefik-demo \ - --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ - nginx:1.29.3 - ``` + ```console + $ docker run -d --network=traefik-demo \ + --label 'traefik.http.routers.nginx.rule=Host(`nginx.localhost`)' \ + nginx:1.29.3 + ``` - {{< /tab >}} - {{< /tabs >}} + {{< /tab >}} + {{< /tabs >}} - 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). + 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). 4. Start a second application that will use a different hostname. - ```console - $ docker run -d --network=traefik-demo --label 'traefik.http.routers.welcome.rule=Host(`welcome.localhost`)' docker/welcome-to-docker - ``` + ```console + $ docker run -d --network=traefik-demo --label 'traefik.http.routers.welcome.rule=Host(`welcome.localhost`)' docker/welcome-to-docker + ``` - Once the container starts, open your browser to http://welcome.localhost. You should see a “Welcome to Docker” website. + Once the container starts, open your browser to http://welcome.localhost. You should see a “Welcome to Docker” website. ## Using Traefik in development From 0155444f7cfd53ebff909ef794b2a7458a904ed1 Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari Date: Fri, 13 Feb 2026 19:14:13 +0330 Subject: [PATCH 16/16] fix: another steps Signed-off-by: MohammadHasan Akbari --- content/guides/traefik.md | 168 +++++++++++++++++++------------------- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/content/guides/traefik.md b/content/guides/traefik.md index 3058b304041d..00fce41479d0 100644 --- a/content/guides/traefik.md +++ b/content/guides/traefik.md @@ -143,114 +143,114 @@ The application can be accessed on GitHub at [dockersamples/easy-http-routing-wi 1. In the `compose.yaml` file, Traefik is using the following configuration: - {{< tabs >}} - {{< tab name="Using DHI image" >}} - - ```yaml - services: - proxy: - image: dhi.io/traefik:3.6.2 - command: --providers.docker - ports: - - 80:80 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - ``` - - {{< /tab >}} + {{< tabs >}} + {{< tab name="Using DHI image" >}} + + ```yaml + services: + proxy: + image: dhi.io/traefik:3.6.2 + command: --providers.docker + ports: + - 80:80 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + ``` - {{< tab name="Using official image" >}} + {{< /tab >}} - ```yaml - services: - proxy: - image: traefik:v3.6.2 - command: --providers.docker - ports: - - 80:80 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - ``` + {{< tab name="Using official image" >}} + + ```yaml + services: + proxy: + image: traefik:v3.6.2 + command: --providers.docker + ports: + - 80:80 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + ``` - {{< /tab >}} - {{< /tabs >}} + {{< /tab >}} + {{< /tabs >}} - Note that this is essentially the same configuration as used earlier, but now in a Compose syntax. + Note that this is essentially the same configuration as used earlier, but now in a Compose syntax. 2. The client service has the following configuration, which will start the container and provide it with the labels to receive requests at localhost. - {{< tabs >}} - {{< tab name="Using Docker Hardened Images" >}} - - Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). + {{< tabs >}} + {{< tab name="Using Docker Hardened Images" >}} - If you haven't authenticated yet, first run: + Docker Hardened Images (DHI) for Nginx are available on [Nginx DHI image](https://hub.docker.com/hardened-images/catalog/dhi/nginx). - ```bash - docker login dhi.io - ``` + If you haven't authenticated yet, first run: - You can use it as your base image as shown following: + ```bash + $ docker login dhi.io + ``` - ```yaml - services: - # … - client: - image: dhi.io/nginx:1.29.3-alpine3.21 - volumes: - - "./client:/usr/share/nginx/html" - labels: - traefik.http.routers.client.rule: "Host(`localhost`)" - ``` + You can use it as your base image as shown following: + + ```yaml + services: + # … + client: + image: dhi.io/nginx:1.29.3-alpine3.21 + volumes: + - "./client:/usr/share/nginx/html" + labels: + traefik.http.routers.client.rule: "Host(`localhost`)" + ``` - {{< /tab >}} + {{< /tab >}} - {{< tab name="Using the official image" >}} + {{< tab name="Using the official image" >}} - ```yaml - services: - # … - client: - image: nginx:1.29.3-alpine3.22 - volumes: - - "./client:/usr/share/nginx/html" - labels: - traefik.http.routers.client.rule: "Host(`localhost`)" - ``` + ```yaml + services: + # … + client: + image: nginx:1.29.3-alpine3.22 + volumes: + - "./client:/usr/share/nginx/html" + labels: + traefik.http.routers.client.rule: "Host(`localhost`)" + ``` - {{< /tab >}} - {{< /tabs >}} + {{< /tab >}} + {{< /tabs >}} 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. - ```yaml {hl_lines=[7,8]} - services: - # … - api: - build: ./dev/api - volumes: - - "./api:/var/www/html/api" - labels: - traefik.http.routers.api.rule: "Host(`localhost`) && PathPrefix(`/api`)" - ``` + ```yaml {hl_lines=[7,8]} + services: + # … + api: + build: ./dev/api + volumes: + - "./api:/var/www/html/api" + labels: + traefik.http.routers.api.rule: "Host(`localhost`) && PathPrefix(`/api`)" + ``` 4. And finally, the `phpmyadmin` service is configured to receive requests for the hostname “db.localhost”. The service also has environment variables defined to automatically log in, making it a little easier to get into the app. - ```yaml {hl_lines=[5,6]} - services: - # … - phpmyadmin: - image: phpmyadmin:5.2.1 - labels: - traefik.http.routers.db.rule: "Host(`db.localhost`)" - environment: - PMA_USER: root - PMA_PASSWORD: password - ``` + ```yaml {hl_lines=[5,6]} + services: + # … + phpmyadmin: + image: phpmyadmin:5.2.1 + labels: + traefik.http.routers.db.rule: "Host(`db.localhost`)" + environment: + PMA_USER: root + PMA_PASSWORD: password + ``` 5. Before starting the stack, stop the Nginx container if it is still running. - 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. + 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. ## Sending traffic to non-containerized workloads