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

Docker in docker test fails with "Error while fetching server API version" #329

Closed
tillahoffmann opened this issue Apr 11, 2023 · 10 comments · Fixed by #368
Closed

Docker in docker test fails with "Error while fetching server API version" #329

tillahoffmann opened this issue Apr 11, 2023 · 10 comments · Fixed by #368

Comments

@tillahoffmann
Copy link
Collaborator

tillahoffmann commented Apr 11, 2023

The core/tests/test_docker_in_docker.py::test_wait_for_logs_docker_in_docker test has started failing in CI without an obvious reason (see here for an example run). docker/docker-py#2717 may be related. @Duchadian, do you have thoughts on this?

FAILED core/tests/test_docker_in_docker.py::test_wait_for_logs_docker_in_docker - 
docker.errors.DockerException: Error while fetching server API version: 
HTTPConnectionPool(host='172.17.0.2', port=2375): Max retries exceeded with url: 
/version (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fda5372d090>: 
Failed to establish a new connection: [Errno 111] Connection refused'))
@dfioravanti
Copy link

dfioravanti commented Apr 12, 2023

I have the same problem on a M1 Mac. All of a sudden it started to crash. I guess it has something to do with the new version of Docker, I upgraded yesterday, until then it worked.

Edit: I can confirm that downgrading makes testcontainers work again

@tillahoffmann
Copy link
Collaborator Author

Thanks for reporting, @dfioravanti. I also observe the issue on my M1.

Edit: I can confirm that downgrading makes testcontainers work again

Which version did you use to make the docker-in-docker tests work again?

@dfioravanti
Copy link

Hey @tillahoffmann, sorry I should have been more precise. I have this problem on docker desktop. In the gitlab CI we use it still works, but that runs on linux. In any case, locally I am running 4.16.2 (95914). It was just the installer that I had laying around. No other reason. I tried to look up on the docker github page but I cannot see any report that might explain this and I did not have time yet to really start digging to see if I can find what is going on and open a proper bug report

@Duchadian
Copy link
Contributor

@tillahoffmann, there's a decent number of things that could have caused this as far as I can see. I don't think the CI failing suddenly and that you and @dfioravanti are seeing issues with a new version of docker desktop are unrelated.

There's probably been some change in how the docker api behaves in the new version (could be a change in endpoint, response, tls, etc.) that the docker client can't deal with, but it's strange that it only shows up with the DinD tests. My guess is some sort of verification on the calls to the docker api, but that's nothing more than my best guess without having looked into it at all.

I'll look into this when I have the time, which will probably be after the weekend.

@gooner22
Copy link

in my case issue appeared after Docker Desktop upgrade v4.21.1 on M1.
fixed by enabling /var/run/docker.sock in Advanced settings in docker client:

Allow the default Docker socket to be used (requires password)
Creates /var/run/docker.sock which some third-party clients may use to communicate with Docker Desktop. [Learn more⁠](https://docs.docker.com/desktop/mac/permission-requirements)

@dfioravanti
Copy link

@gooner22 Thanks a lot, I forgot how I had fixed this and I had the same problem on a new machine. I have no idea why I did not comment my solution here 🤦 You saved me quite a lot of work finding it out

@moonbrv
Copy link

moonbrv commented Aug 18, 2023

@gooner22 Thanks! I had it enabled, but after disable+enable it fixed my issue

@rogelioLpz
Copy link

@gooner22 thanks a lot!
That works for me!! 🎉 🎉

@FRosner
Copy link

FRosner commented Feb 28, 2024

I'm also running into this. I use colima and my docker socket is located under unix://${HOME}/.colima/default/docker.sock. Is there a way to get it to use this one?

In Java it seems to work, because it respects ~/.testcontainers.properties.

cat ~/.testcontainers.properties

docker.client.strategy=org.testcontainers.dockerclient.UnixSocketClientProviderStrategy
docker.host=unix:///Users/frosner/.colima/default/docker.sock

Edit: As a workaround, you can export DOCKER_HOST="unix://${HOME}/.colima/default/docker.sock"

alexanderankin pushed a commit that referenced this issue Mar 24, 2024

Verified

This commit was signed with the committer’s verified signature.
MadVikingGod Aaron Clawson
🤖 I have created a release *beep* *boop*
---


##
[4.2.0](testcontainers-v4.1.0...testcontainers-v4.2.0)
(2024-03-24)


### Features

* support influxdb
([#413](#413))
([13742a5](13742a5))


### Bug Fixes

* **arangodb:** tests to pass on ARM CPUs - change default image to
3.11.x where ARM image is published
([#479](#479))
([7b58a50](7b58a50))
* **core:** DinD issues
[#141](#141),
[#329](#329)
([#368](#368))
([b10d916](b10d916))
* **core:** raise an exception when docker compose fails to start
[#258](#258)
([#485](#485))
([d61af38](d61af38))
* **core:** use auto_remove=True with reaper instance
([#499](#499))
([274a400](274a400))
* **docs:** update the non-existent main.yml badge
([#493](#493))
([1d10c1c](1d10c1c))
* Fix the return type of `DockerContainer.get_logs`
([#487](#487))
([cd72f68](cd72f68))
* **keycloak:** tests on aarch64, use image from [jboss -&gt; quay],
change supported version [16+ -> 18+]
([#480](#480))
([5758310](5758310))
* **postgres:** doctest
([#473](#473))
([c9c6f92](c9c6f92))
* read the docs build works again
([#496](#496))
([dfd1781](dfd1781))
* readthedocs build - take 1
([#495](#495))
([b3b9901](b3b9901))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
bearrito pushed a commit to bearrito/testcontainers-python that referenced this issue Mar 30, 2024

Verified

This commit was signed with the committer’s verified signature.
MadVikingGod Aaron Clawson
…ntainers#368)

Fix testcontainers#141 - find IP from custom network if the container is not using the
default network
Close testcontainers#329 - This seems fixed in the underlying docker libraries.
Improve support for Docker in Docker running on a custom network, by
attempting to find the right custom network and use it for new
containers. This adds support for using testcontainers-python running
the GitHub Actions Runner Controller to run self-hosted actions runners
on prem, when you run your workflows in containers.

---------

Co-authored-by: Dee Moore <dee42moore@gmail.com>
Co-authored-by: David Ankin <daveankin@gmail.com>
Co-authored-by: Balint Bartha <39852431+totallyzen@users.noreply.github.com>
bearrito pushed a commit to bearrito/testcontainers-python that referenced this issue Mar 30, 2024

Verified

This commit was signed with the committer’s verified signature.
MadVikingGod Aaron Clawson
🤖 I have created a release *beep* *boop*
---


##
[4.2.0](testcontainers/testcontainers-python@testcontainers-v4.1.0...testcontainers-v4.2.0)
(2024-03-24)


### Features

* support influxdb
([testcontainers#413](testcontainers#413))
([13742a5](testcontainers@13742a5))


### Bug Fixes

* **arangodb:** tests to pass on ARM CPUs - change default image to
3.11.x where ARM image is published
([testcontainers#479](testcontainers#479))
([7b58a50](testcontainers@7b58a50))
* **core:** DinD issues
[testcontainers#141](testcontainers#141),
[testcontainers#329](testcontainers#329)
([testcontainers#368](testcontainers#368))
([b10d916](testcontainers@b10d916))
* **core:** raise an exception when docker compose fails to start
[testcontainers#258](testcontainers#258)
([testcontainers#485](testcontainers#485))
([d61af38](testcontainers@d61af38))
* **core:** use auto_remove=True with reaper instance
([testcontainers#499](testcontainers#499))
([274a400](testcontainers@274a400))
* **docs:** update the non-existent main.yml badge
([testcontainers#493](testcontainers#493))
([1d10c1c](testcontainers@1d10c1c))
* Fix the return type of `DockerContainer.get_logs`
([testcontainers#487](testcontainers#487))
([cd72f68](testcontainers@cd72f68))
* **keycloak:** tests on aarch64, use image from [jboss -&gt; quay],
change supported version [16+ -> 18+]
([testcontainers#480](testcontainers#480))
([5758310](testcontainers@5758310))
* **postgres:** doctest
([testcontainers#473](testcontainers#473))
([c9c6f92](testcontainers@c9c6f92))
* read the docs build works again
([testcontainers#496](testcontainers#496))
([dfd1781](testcontainers@dfd1781))
* readthedocs build - take 1
([testcontainers#495](testcontainers#495))
([b3b9901](testcontainers@b3b9901))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@gpkc
Copy link

gpkc commented Dec 6, 2024

FYI I was able to make it work with the ~/.testcontainers.properties file by setting tc.host instead of docker.host

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

Successfully merging a pull request may close this issue.

8 participants