polar
polar copied to clipboard
Bug: DOCKER_HOST environment variable not respected
Describe the bug Polar fails to connect to Docker on startup and shows the "Docker Not Detected" message even though the system should be compatible.
To Reproduce
Run the docker daemon on a different host than the standard /var/run/docker.sock
.
Expected behavior
I believe that the DOCKER_HOST
environment variable is the standard way to direct programs (e.g. Docker Compose) to the correct socket to use to contact the local docker daemon. Assuming that is set correctly, Polar should use it.
Desktop (please complete the following information):
- OS: Linux
- Polar Version: 1.3.0
- Docker Compose Version: 1.29.2
Additional context
I am using a non-standard docker install that puts the DOCKER_HOST
on a different socket than usual, but I don't think this should effect Polar.
My DOCKER_HOST
is set to unix:///run/user/1000/podman/podman.sock
, but I see in the Polar logs it still tries to connect to /var/run/docker.sock
:
14:56:09.308 › Failed: connect EACCES /var/run/docker.sock
My only guess is that this has something to do with the dockerode
dependency? For what its worth, it appears that once Polar is started, it respects DOCKER_HOST
. I believe this is due to it delegating to Compose.
My only guess is that this has something to do with the
dockerode
dependency? For what its worth, it appears that once Polar is started, it respectsDOCKER_HOST
. I believe this is due to it delegating to Compose.
Yes, I would have made this same guess as you, but after looking at the dockerode
source code, I've found that it uses docker-modem
to talk to Docker. docker-modem
does indeed inspect DOCKER_HOST
in modem.js. So the issue may be that the env vars aren't being properly passed to the Electron app. Which Linux distro are you using? I can try to do more testing when time permits.
I am running Arch. I'm happy to do some more debugging as well, I'll try to see if I can track it down to electron.
Awesome! That would be very helpful. Thanks 🥇
I poked around about and believe this is the root of the issue: https://github.com/electron/electron/issues/3306
I verified that the main electron process has the correct DOCKER_HOST env var. And it appears the the "zygot" subprocess don't when I inspected their /proc/$PID/environ
. I am not sure the best path forward though, new to the electron framework.
EDIT: As a workaround I was able to hardcode the socketPath
locally here: https://github.com/jamaljsr/polar/blob/master/src/lib/docker/dockerService.ts#L36, but I think the ideal solution would be to have it pull from the remote's DOCKER_HOST env var similar to the logic in getArgs
which is passed to all the compose calls.
Thank for looking into this. 👍
I haven't confirmed myself but that electron issue seems like it could be the issue. I'll work on a fix when time permits.
This was fixed in #695