Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve support for alternative container runtimes #9140

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tjamet
Copy link

@tjamet tjamet commented Aug 22, 2024

In several cases, alternative container runtimes offers a docker compatible API and populates the docker context accordingly.

However, in the current implementation of testcontainers, the context is often ignored as the EnvironmentAndSystemPropertyClientProviderStrategy only considers the DOCKER_HOST override either through testcontainers property or the environment variables.

Improve the support of multiple container runtimes by honoring the current docker context.

In addition, improve the detection of whether the Docker engine runs in a virtual machine without root access for the current user, so it removes the need to configure TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE in standard cases.

This change has been tested with:

  • colima
  • rancher desktop (in non-privileged mode)
  • docker desktop
  • orbstack

In several cases, alternative container runtimes offers a docker
compatible API and populates the docker context accordingly.

However, in the current implementation of testcontainers, the context is
often ignored as the `EnvironmentAndSystemPropertyClientProviderStrategy` only considers
the `DOCKER_HOST` override either through testcontainers property or the
environment variables.

Improve the support of multiple container runtimes by honoring the
current docker context.

In addition, improve the detection of whether the Docker engine runs
in a virtual machine without root access for the current user, so it
removes the need to configure `TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE` in
standard cases.

This change has been tested with:
- colima
- rancher desktop (in non-privileged mode)
- docker desktop
- orbstack
@tjamet tjamet requested a review from a team as a code owner August 22, 2024 17:35
@eddumelendez
Copy link
Member

Thanks for your contribution, @tjamet. Can you please run ./gradlew spotlessApply? or give me access to update the branch, please.

Copy link
Member

@kiview kiview left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, we only need to check, whether this might accidentally break RootlessDockerClientProviderStrategy, since in this case, the socket might also be in the home directory, but should not resolve to /var/run/docker.sock for getRemoteDockerUnixSocketPath().

docker context use colima
```

For more complex scenarios you should configure the following environment variables:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these docs can even be removed, to avoid confusion, right?
Same for the Podman and Rancher docs I guess?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants