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

No Docker client strategy found on mac m1 #407

Closed
Tenshock opened this issue Oct 24, 2022 · 17 comments
Closed

No Docker client strategy found on mac m1 #407

Tenshock opened this issue Oct 24, 2022 · 17 comments
Labels
triage Investigation required

Comments

@Tenshock
Copy link

Expected Behaviour
when launching tests from elastic search module file, I expect the tests to pass

Actual Behaviour
When launching tests, I have the following error:

Error: No Docker client strategy found

    at /Users/myUser/repo/export/at-elasticsearch-indexmapper/node_modules/testcontainers/dist/docker/docker-client.js:46:11

After checking, my only socket related to docker in /var/run is com.docker.vmnetd.sock

Testcontainer Logs

  testcontainers DEBUG Found applicable Docker client strategy: UnixSocketStrategy +0ms
  testcontainers DEBUG Testing Docker client strategy URI: unix:///var/run/docker.sock +1ms
  testcontainers WARN  Docker daemon is not reachable: Error: connect ENOENT /var/run/docker.sock +4ms
  testcontainers WARN  Docker client strategy UnixSocketStrategy is not reachable +0ms

Steps to Reproduce

I checked that docker is properly running (I can docker ps, docker run hello-world without problem)

  1. Clone project [email protected]:Tenshock/testcontainers.git
  2. Run yarn
  3. Run yarn test
  4. See error in section Actual Behaviour

Environment Information

  • Operating System: macOS Monterey Version 12.6 on Apple M1 Pro
  • Docker Version: Docker version 20.10.20, build 9fdeb9c (Installed from brew install --cask docker)
  • Node version: v16.17.0
  • Testcontainers version: 8.16.0
@cristianrgreco
Copy link
Collaborator

Hi @Tenshock, by default I'd expect the Docker daemon to create the socket /var/run/docker.sock. I'm also on an M1 mac and that's how it is for me on the same version of Docker. Could you please investigate why that socket does not exist?

@cristianrgreco cristianrgreco added the triage Investigation required label Oct 24, 2022
@Tenshock
Copy link
Author

I’d expect it as well, I will reset to factory my docker desktop configuration, uninstall all docker related stuff (docker and cask docker) and I will reinstall it to see if I have the same behavior

did you installed docker desktop? And if so, through brew or with the official dmg from docker website?

@cristianrgreco
Copy link
Collaborator

cristianrgreco commented Oct 24, 2022

Thanks @Tenshock, please let me know how it goes. I installed Docker Desktop through the website https://docs.docker.com/desktop/install/mac-install/ (Mac with Apple Chip)

@Tenshock
Copy link
Author

Tenshock commented Oct 24, 2022

I uninstalled everything (I uninstalled from the docker desktop application first then from brew cli), the deamon was successfully deleted.

I reinstalled only docker desktop from the website, with the same deamon (com.docker.vmnetd.sock) being created. The problem still persists

@Tenshock
Copy link
Author

It appears like it's a problem with docker, not testcontainers. You can close this thread so, I will finish to debug by my own or in a proper place :)

Thanks for your reactivity

@Tenshock
Copy link
Author

Tenshock commented Oct 24, 2022

FYI and for maybe next readers with same problem: I had to create the symlink by hand (sudo ln -sf /Users/myUser/.docker/run/docker.sock /var/run/docker.sock), the patch is not that awful but quite annoying

I don't know why it was not created automatically, I'll try to troubleshoot it later

@cristianrgreco
Copy link
Collaborator

Interesting, the socket was in your home dir instead of available for everyone. Maybe it was an option in the installation to install only for your user?

@Tenshock
Copy link
Author

Tenshock commented Oct 25, 2022

Maybe, after reading all setups configurations, I did not found any configuration to setup this …

Apparently, it is an issue, following this issue: docker/for-mac#6529

The part: "Docker Desktop for Mac removed /var/run/docker.sock per 4.13.0 Release Notes: https://docs.docker.com/desktop/release-notes/#docker-desktop-4130 "By default Docker will not create the /var/run/docker.sock symlink on the host and use the docker-desktop CLI context instead."" is interesting ^^

I set the DOCKER_HOST environment variable to unix:///Users/myUser/.docker/run/docker.sock, it resolves the problem with the current implementation of testcontainers and is cleaner.

But it's an additional step, I will follow this issue

Which version of Docker Desktop do you use?

@itsravenous
Copy link

itsravenous commented Nov 19, 2022

Just as a note, the same problem exists with Docker Desktop on Linux, and the /var/run/docker.sock symlink was not restored in v4.13.1 as it was in Mac. The DOCKER_HOST env var workaround does work, however - e.g:

DOCKER_HOST=unix:///home/youruser/.docker/run/docker.sock

@kbariotis
Copy link

I'm facing the exact same issue but I'm using Rancher Desktop, Im not sure if that would make any difference. I symlinked the socket file from home directory but the error still comes up.

image

@itsravenous
Copy link

How odd. Have you tried setting the DOCKER_HOST env var? In your case:

DOCKER_HOST=unix:///Users/konstantinosbariotis/.docker/run/docker.sock node index.js

@kbariotis
Copy link

yes @itsravenous I did and its just the same. :/

@itsravenous
Copy link

itsravenous commented Nov 23, 2022

I haven't used Rancher Desktop, but as mentioned above, Docker desktop restored the previous location of the docker socket in 14.13.1. If you're not on the latest version of Rancher desktop, perhaps upgrading will help? Otherwise I'd suggest asking in the Rancher Desktop community for help.

@kbariotis
Copy link

kbariotis commented Nov 23, 2022

ok @itsravenous thank you I think I found the issue, the symlink was actually not right. The right path of RD's socket is in /Users/${USER}/.rd/docker.sock and that's where the /var/run/docker.sock should be pointing to. :) thank you for your time thought :)

Im not sure what's the .docker folder in the home directory, maybe its been left from a previous Docker Desktop installation.

@itsravenous
Copy link

ok @itsravenous thank you I think I found the issue, the symlink was actually not right. The right path of RD's socket is in /Users/${USER}/.rd/docker.sock and that's where the /var/run/docker.sock should be pointing to. :) thank you for your time thought :)

Im not sure what's the .docker folder in the home directory, maybe its been left from a previous Docker Desktop installation.

That sounds about right! Glad you got it sorted 😁

@razor-x
Copy link

razor-x commented Dec 29, 2022

Looks like they realized the missing socket broke "all the things", so the socket systemlink has been added back in on docker desktop for Mac, but sadly not for linux.

image

Docker tooling like this will need a solution for handling the case where only the userspace socket exists and not /var/run/docker.sock, otherwise there will be a lot of issues like this one where mac users are ok but linux users are still broken. Does anyone know if there is a standard way to get the socket location, maybe from the active docker context?

@mxngls
Copy link

mxngls commented Feb 27, 2023

Follow-up for everyone that's using Colima instead of Docker-Desktop due to licensing issues: We have to create a symlink as indicated in other comments above:

sudo ln -sf /Users/${USER}/.colima/docker.sock /var/run/docker.sock;

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

No branches or pull requests

6 participants