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

`Error in the hyper legacy client: client error (Connect)` on Windows

Open tamaroning opened this issue 1 year ago • 4 comments

Hello, I got this error when attempting to start a container on Windows.

Error:

thread 'foo' panicked at C:\Users\<me>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\testcontainers-0.16.7\src\runners\async_runner.rs:204:29:
Error in the hyper legacy client: client error (Connect)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace 

I have installed Docker Desktop on Windows and Docker on WSL2. ~/.testcontainers.properties or DOCKER_HOST were not set.

I have read the docs but could not find what values I should set. How can I fix the error? Thank you in advance.

tamaroning avatar May 09 '24 15:05 tamaroning

Hi @tamaroning 👋

For Windows the default socket is npipe:////./pipe/docker_engine. But that's should be overridden, since you use WSL. You can try to set DOCKER_HOST=tcp://localhost:2375. Don't really remember defaults for Windows+WSL setup, but if this doesn't help, you will need expose the docker through TCP socket manually.

We definitely need to improve the documentation to cover this topic better.

DDtKey avatar May 09 '24 16:05 DDtKey

Please, let me know if it solves your issue.

DDtKey avatar May 14 '24 18:05 DDtKey

For anyone else driving by, the same is necessary on MacOS with Colima (and presumably any non-Docker container VM). I used export DOCKER_HOST="unix://${HOME}/.colima/default/docker.sock". I don't recall having to do this for older versions of testcontainers-rs, but it's not a big deal to throw this in ~/.zshrc.

inahga avatar May 14 '24 21:05 inahga

I don't recall having to do this for older versions of testcontainers-rs, but it's not a big deal to throw this in ~/.zshrc

Yes, that's because we got rid of CLI client, which was more like a temporary solution from the very beginning (with its pros and cons)


Just in order to extend the context:

Now we utilize Docker compatible API, and docker host resolution was described in migration guide for 16.0.0 version and also mentioned in docs.rs (as well as docker authentication process)

Not exhaustive list of benefits:

  • that's more flexible and allows to use remote docker or dedicated one for testing (especially common in CI)
  • we have an aligned interface, much easier to use and maintain
  • we don't need to have docker CLI locally to run tests (or any other CLI)
  • Testcontainers works this way for other languages too, so you can run test-suites written in different languages with the same config

And the main cost for that is the additional configuration only in some cases.

Reference to a similar issue: https://github.com/testcontainers/testcontainers-rs/issues/625

DDtKey avatar May 15 '24 02:05 DDtKey

I'm going to close the issue due to inactivity. Please, don't hesitate to re-open if you feel the provided information is insufficient.

DDtKey avatar May 19 '24 02:05 DDtKey