Skip to content

Custom Configuration

Testcontainers supports various configurations to set up your test environment. It automatically discovers the Docker environment and applies the configuration. You can set or override the default values either with the Testcontainers properties file (~/ or with environment variables. If you prefer to configure your test environment at runtime, you can set or override the configuration through the TestcontainersSettings class. The following configurations are available:

Properties File Environment Variable Description Default
docker.config DOCKER_CONFIG The directory path that contains the Docker configuration (config.json) file. ~/.docker/ DOCKER_HOST The Docker daemon socket to connect to. -
docker.auth.config DOCKER_AUTH_CONFIG The Docker configuration file content (GitLab: Use statically-defined credentials). -
docker.cert.path DOCKER_CERT_PATH The directory path that contains the client certificate ({ca,cert,key}.pem) files. ~/.docker/
docker.tls DOCKER_TLS Enables TLS. false
docker.tls.verify DOCKER_TLS_VERIFY Enables TLS verify. false
host.override TESTCONTAINERS_HOST_OVERRIDE The host that exposes Docker's ports. -
docker.socket.override TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE The file path to the Docker daemon socket that is used by Ryuk (resource reaper). /var/run/docker.sock
ryuk.disabled TESTCONTAINERS_RYUK_DISABLED Disables Ryuk (resource reaper). false
ryuk.container.privileged TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED Runs Ryuk (resource reaper) in privileged mode. false
ryuk.container.image TESTCONTAINERS_RYUK_CONTAINER_IMAGE The Ryuk (resource reaper) Docker image. testcontainers/ryuk:0.3.4 TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX The name to use for substituting the Docker Hub registry part of the image name. -

Enable logging

In .NET logging goes usually through the test framework. Testcontainers is not aware of the project's test framework and may not forward log messages to the right stream. The default implementation forwards log messages to the Console (respectively stdout and stderr) and Debug. The output should at least pop up in the IDE running tests in the Debug configuration. To override the default implementation, set the TestcontainersSettings.Logger property to an instance of an ILogger implementation.

[ 00:00:00.34] Connected to Docker:
  Host: tcp://
  Server Version: 70+testcontainerscloud
  Kernel Version: 5.10.137
  API Version: 1.41
  Operating System: Ubuntu 20.04 LTS
  Total Memory: 7.23 GB
[ 00:00:00.47] Searching Docker registry credential in CredHelpers
[ 00:00:00.47] Searching Docker registry credential in Auths
[ 00:00:00.47] Searching Docker registry credential in CredsStore
[ 00:00:00.47] Searching Docker registry credential in Auths
[ 00:00:00.51] Docker registry credential found
[ 00:00:03.16] Docker image testcontainers/ryuk:0.3.4 created
[ 00:00:03.24] Docker container b6fad46fbcec84625281c1401ec91158b25cad6495fa612274af7c920abec14e created
[ 00:00:03.29] Start Docker container b6fad46fbcec84625281c1401ec91158b25cad6495fa612274af7c920abec14e
[ 00:00:06.18] Docker image alpine:latest created
[ 00:00:06.22] Docker container 027af397344d08d5fc174bf5b5d449f6b352a8a506306d3d96390aaa2bb0445d created
[ 00:00:06.26] Start Docker container 027af397344d08d5fc174bf5b5d449f6b352a8a506306d3d96390aaa2bb0445d
[ 00:00:06.64] Delete Docker container 027af397344d08d5fc174bf5b5d449f6b352a8a506306d3d96390aaa2bb0445d