From b77d98bbbb74ce052424ec47ad14497a09d2644a Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Wed, 11 Jan 2023 11:16:52 +0100 Subject: [PATCH 1/4] docs: Add Docker Desktop Compose example --- docs/examples/compose.md | 22 ++++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 23 insertions(+) create mode 100644 docs/examples/compose.md diff --git a/docs/examples/compose.md b/docs/examples/compose.md new file mode 100644 index 000000000..3ec865cfe --- /dev/null +++ b/docs/examples/compose.md @@ -0,0 +1,22 @@ +# Compose + +## Docker Desktop + +To use Docker's Compose tool to build and run a Testcontainers environment in a Docker Desktop Wormhole configuration, +it is necessary to override Testcontainers Docker host resolution and set the environment variable `TESTCONTAINERS_HOST_OVERRIDE` to `host.docker.internal`. +Otherwise, Testcontainers cannot access sibling containers like the Resource Reaper Ryuk or other services running on the Docker's host. +A minimal `docker-compose.yml` file that builds a new container image and runs the test inside the container look something like: + +```Yaml +version: "3" +services: + docker_compose_test: + build: + dockerfile: Dockerfile + context: . + entrypoint: dotnet test + environment: + - TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal + volumes: + - /var/run/docker.sock:/var/run/docker.sock +``` diff --git a/mkdocs.yml b/mkdocs.yml index e39610ebb..f4eb38359 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -30,6 +30,7 @@ nav: - api/resource-reaper.md - api/wait_strategies.md - Examples: + - examples/compose.md - examples/aspnet.md - Modules: - modules/index.md From d5fe893371c82e0894459075882ad83b4d6a728e Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Mon, 16 Jan 2023 11:13:28 +0100 Subject: [PATCH 2/4] Update docs/examples/compose.md --- docs/examples/compose.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/examples/compose.md b/docs/examples/compose.md index 3ec865cfe..92c99cce4 100644 --- a/docs/examples/compose.md +++ b/docs/examples/compose.md @@ -14,7 +14,8 @@ services: build: dockerfile: Dockerfile context: . - entrypoint: dotnet test + entrypoint: dotnet + command: test environment: - TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal volumes: From d73f84d35c6b1b366b1f25502b74abfacf646399 Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Mon, 16 Jan 2023 11:13:37 +0100 Subject: [PATCH 3/4] Update docs/examples/compose.md Co-authored-by: Kevin Wittek --- docs/examples/compose.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/compose.md b/docs/examples/compose.md index 92c99cce4..8e3147c30 100644 --- a/docs/examples/compose.md +++ b/docs/examples/compose.md @@ -3,7 +3,7 @@ ## Docker Desktop To use Docker's Compose tool to build and run a Testcontainers environment in a Docker Desktop Wormhole configuration, -it is necessary to override Testcontainers Docker host resolution and set the environment variable `TESTCONTAINERS_HOST_OVERRIDE` to `host.docker.internal`. +it is necessary to override Testcontainers' Docker host resolution and set the environment variable `TESTCONTAINERS_HOST_OVERRIDE` to `host.docker.internal`. Otherwise, Testcontainers cannot access sibling containers like the Resource Reaper Ryuk or other services running on the Docker's host. A minimal `docker-compose.yml` file that builds a new container image and runs the test inside the container look something like: From 981e56c76294240703bad9b6198f1541c9a720f4 Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Mon, 16 Jan 2023 11:13:41 +0100 Subject: [PATCH 4/4] Update docs/examples/compose.md Co-authored-by: Kevin Wittek --- docs/examples/compose.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/compose.md b/docs/examples/compose.md index 8e3147c30..3176ba841 100644 --- a/docs/examples/compose.md +++ b/docs/examples/compose.md @@ -4,7 +4,7 @@ To use Docker's Compose tool to build and run a Testcontainers environment in a Docker Desktop Wormhole configuration, it is necessary to override Testcontainers' Docker host resolution and set the environment variable `TESTCONTAINERS_HOST_OVERRIDE` to `host.docker.internal`. -Otherwise, Testcontainers cannot access sibling containers like the Resource Reaper Ryuk or other services running on the Docker's host. +Otherwise, Testcontainers cannot access sibling containers like the Resource Reaper Ryuk or other services running on the Docker host. A minimal `docker-compose.yml` file that builds a new container image and runs the test inside the container look something like: ```Yaml