diff --git a/docs/usage/dind.md b/docs/usage/dind.md index 869f55eec76..ded3c0f7de7 100644 --- a/docs/usage/dind.md +++ b/docs/usage/dind.md @@ -1,13 +1,18 @@ # Docker in Docker -Since TestContainers version 1.1.8, you can run your tests inside a container. -It's very useful for different CI scenarios like running everything in containers on Jenkins. +> Since 1.1.8 + +Testcontainers itself can be used from inside a container. +This is very useful for different CI scenarios like running everything in containers on Jenkins, or Docker-based CI tools such as Drone. TestContainers will automatically detect if it's inside a container and instead of "localhost" will use the default gateway's IP. -However, an additional configuration is required if you use [volume mapping](options.md#volume-mapping). +However, additional configuration is required if you use [volume mapping](options.md#volume-mapping). The following points need to be considered: + +* The docker socket must be available via a volume mount +* The 'local' source code directory must be volume mounted *at the same path* inside the container that Testcontainers runs in, so that Testcontainers is able to set up the correct volume mounts for the containers it spawns. -## Docker-only +## Docker-only example If you run the tests with just `docker run ...` then make sure you add `-v $PWD:$PWD -w $PWD -v /var/run/docker.sock:/var/run/docker.sock` to the command, so it will look like this: ```bash $ tree . @@ -26,7 +31,7 @@ Where: * `-w $PWD` will set the current directory to this volume * `-v /var/run/docker.sock:/var/run/docker.sock` will map the Docker socket -## Docker Compose +## Docker Compose example The same can be achived with Docker Compose: ```yaml tests: