In recent Docker Desktop versions on Mac, the socket is moved to the user directory.
As a fallback, there's an optional setting to mount that at /var/run/docker.sock at login, but I'm sure many users won't enable this and so Dockerode will fail to work for them unless DOCKER_HOST is set manually.
I think this is simple to fix: on Mac, if /Users/<user>/.docker/run/docker.sock exists, then that should be used as the default.
This requires a small refactor, since it requires an FS operation and defaultOpts and the Modem constructor are synchronous, but this could be done by accepting a promise as an socketPath option, and waiting for that to resolve during dial (which is async) in that case.
In recent Docker Desktop versions on Mac, the socket is moved to the user directory.
As a fallback, there's an optional setting to mount that at
/var/run/docker.sock
at login, but I'm sure many users won't enable this and so Dockerode will fail to work for them unless DOCKER_HOST is set manually.Some discussion here: https://github.com/docker/for-mac/issues/6529 (this was released in Docker Desktop 4.13, reverted in 4.13.1, and then released for good in 4.18) More info: https://docs.docker.com/desktop/mac/permission-requirements/
I think this is simple to fix: on Mac, if
/Users/<user>/.docker/run/docker.sock
exists, then that should be used as the default.This requires a small refactor, since it requires an FS operation and
defaultOpts
and the Modem constructor are synchronous, but this could be done by accepting a promise as ansocketPath
option, and waiting for that to resolve duringdial
(which is async) in that case.Would you be open to a PR for this?