Skip to content

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

Closed

Description

@tillahoffmann

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'))

Activity

  1. dfioravanti commented on Apr 12, 2023

    @dfioravanti

    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

  2. tillahoffmann commented on Apr 12, 2023

    @tillahoffmann
    ContributorAuthor

    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?

  3. dfioravanti commented on Apr 13, 2023

    @dfioravanti

    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

  4. Duchadian commented on Apr 15, 2023

    @Duchadian
    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.

  5. gooner22 commented on Jul 31, 2023

    @gooner22

    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)
    
  6. dfioravanti commented on Aug 6, 2023

    @dfioravanti

    @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

  7. moonbrv commented on Aug 18, 2023

    @moonbrv

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

  8. rogelioLpz commented on Dec 14, 2023

    @rogelioLpz

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

  9. FRosner commented on Feb 28, 2024

    @FRosner

    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"

  10. added a commit that references this issue on Mar 20, 2024
  11. gpkc commented on Dec 6, 2024

    @gpkc

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions