testcontainers-go icon indicating copy to clipboard operation
testcontainers-go copied to clipboard

[Feature]: Add support for Windows containers

Open pjanotti opened this issue 2 years ago • 4 comments

Problem

(This is based on my experience with v0.19.0.)

testcontainers-go currently doesn't support "Windows containers": it has some hard-coded defaults that don't consider the possibility of Windows containers. Some examples:

  • Below should be "nat" (or "default"?) to support Windows containers: https://github.com/testcontainers/testcontainers-go/blob/447099b908d12a0dd64f4110e995c51ea2933751/docker.go#L52

  • Below should be client.DefaultDockerHost: https://github.com/testcontainers/testcontainers-go/blob/447099b908d12a0dd64f4110e995c51ea2933751/config.go#L58

  • Below should be the named pipe //./pipe/docker_engine: https://github.com/testcontainers/testcontainers-go/blob/447099b908d12a0dd64f4110e995c51ea2933751/reaper.go#L100

  • Below the reaper network should use "default": https://github.com/testcontainers/testcontainers-go/blob/447099b908d12a0dd64f4110e995c51ea2933751/reaper.go#L106

  • By default the reaper network starts a Linux image

  • When checking if the image start was completed it executes a Unix command: https://github.com/testcontainers/testcontainers-go/blob/447099b908d12a0dd64f4110e995c51ea2933751/wait/host_port.go#L170-L175

Solution

Remove the hard-coded locations that are assuming Linux containers and make the proper decisions to have testcontainers-go working with Windows containers.

Benefit

Many projects using golang are intended to be multi-platform and not being able to have containers test with Windows containers limits that capability. This is beneficial to projects that do heavy multi-platform integration tests.

Alternatives

I tried to configure environment variables like DOCKER_HOST or use settings like SkipReaper to get this working but some of the values are hard-coded and completely block this path.

Side note: the testcontainers for .NET supports both Linux and Windows containers so there is already a good reference to look at to make implement this feature.

Would you like to help contributing this feature?

Yes

pjanotti avatar Mar 21 '23 21:03 pjanotti

I see that Windows containers are supported by https://github.com/ory/dockertest so that it can be used as a reference implementation.

pellared avatar Mar 22 '23 08:03 pellared

Indeed. We are working on making Ryuk to be compatible with Windows containers (there is a community contribution on its way), and would love to have Testcontainers for Go working across all platforms, so I'm really happy this conversation was brought up.

@pjanotti feel free to reach out here or in our Slack for an eventual sync on what needs to be done.

Thanks!

mdelapenya avatar Mar 22 '23 08:03 mdelapenya

Hey guys, was wondering if there's any update on this?

abemedia avatar Nov 12 '23 18:11 abemedia