From 4ce4d87cadabbd3a572801a2ac224f3eaefc8023 Mon Sep 17 00:00:00 2001 From: Hiroki Hanada <69666957+hanapedia@users.noreply.github.com> Date: Fri, 28 Jun 2024 23:10:04 +0900 Subject: [PATCH] fix: Rename TC_HOST environment variable to TESTCONTAINERS_HOST_OVERRIDE (#2536) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: replace TC_HOST environment variable with TESTCONTAINERS_HOST_OVERRIDE * docs: update the documentation on how to override host of docker daemon * docs: remove the reference of TC_HOST in documentation --------- Co-authored-by: Manuel de la Peña --- docker.go | 6 +++--- docs/features/networking.md | 2 +- docs/system_requirements/using_podman.md | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docker.go b/docker.go index c808c6fcb9..16a128cc47 100644 --- a/docker.go +++ b/docker.go @@ -156,7 +156,7 @@ func (c *DockerContainer) PortEndpoint(ctx context.Context, port nat.Port, proto // Host gets host (ip or name) of the docker daemon where the container port is exposed // Warning: this is based on your Docker host setting. Will fail if using an SSH tunnel -// You can use the "TC_HOST" env variable to set this yourself +// You can use the "TESTCONTAINERS_HOST_OVERRIDE" env variable to set this yourself func (c *DockerContainer) Host(ctx context.Context) (string, error) { host, err := c.provider.DaemonHost(ctx) if err != nil { @@ -1349,7 +1349,7 @@ func (p *DockerProvider) Config() TestcontainersConfig { // DaemonHost gets the host or ip of the Docker daemon where ports are exposed on // Warning: this is based on your Docker host setting. Will fail if using an SSH tunnel -// You can use the "TC_HOST" env variable to set this yourself +// You can use the "TESTCONTAINERS_HOST_OVERRIDE" env variable to set this yourself func (p *DockerProvider) DaemonHost(ctx context.Context) (string, error) { return daemonHost(ctx, p) } @@ -1359,7 +1359,7 @@ func daemonHost(ctx context.Context, p *DockerProvider) (string, error) { return p.hostCache, nil } - host, exists := os.LookupEnv("TC_HOST") + host, exists := os.LookupEnv("TESTCONTAINERS_HOST_OVERRIDE") if exists { p.hostCache = host return p.hostCache, nil diff --git a/docs/features/networking.md b/docs/features/networking.md index ca0a53f7e4..69343b47c6 100644 --- a/docs/features/networking.md +++ b/docs/features/networking.md @@ -45,7 +45,7 @@ It is normally advisable to use `Host` and `MappedPort` together when constructi !!! info - Setting the `TC_HOST` environment variable overrides the host of the docker daemon where the container port is exposed. For example, `TC_HOST=172.17.0.1`. + Setting the `TESTCONTAINERS_HOST_OVERRIDE` environment variable overrides the host of the docker daemon where the container port is exposed. For example, `TESTCONTAINERS_HOST_OVERRIDE=172.17.0.1`. ## Exposing host ports to the container diff --git a/docs/system_requirements/using_podman.md b/docs/system_requirements/using_podman.md index fae9731a65..cf65792bbd 100644 --- a/docs/system_requirements/using_podman.md +++ b/docs/system_requirements/using_podman.md @@ -3,7 +3,7 @@ _Testcontainers for Go_ supports the use of Podman (rootless or rootful) instead of Docker. In most scenarios no special setup is required in _Testcontainers for Go_. -_Testcontainers for Go_ will automatically discover the socket based on the `DOCKER_HOST` or the `TC_HOST` environment variables. +_Testcontainers for Go_ will automatically discover the socket based on the `DOCKER_HOST` environment variables. Alternatively you can configure the host with a `.testcontainers.properties` file. The discovered Docker host is taken into account when starting a reaper container. The discovered socket is used to detect the use of Podman.