Skip to content

Commit

Permalink
fix: Rename TC_HOST environment variable to TESTCONTAINERS_HOST_OVERR…
Browse files Browse the repository at this point in the history
…IDE (testcontainers#2536)

* 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 <[email protected]>
  • Loading branch information
hanapedia and mdelapenya authored Jun 28, 2024
1 parent 865a70e commit 4ce4d87
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/features/networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ It is normally advisable to use `Host` and `MappedPort` together when constructi
<!--/codeinclude-->

!!! 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

Expand Down
2 changes: 1 addition & 1 deletion docs/system_requirements/using_podman.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 4ce4d87

Please sign in to comment.