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

Bug: DOCKER_HOST environment variable not respected #482

Closed
nyonson opened this issue Aug 10, 2021 · 6 comments
Closed

Bug: DOCKER_HOST environment variable not respected #482

nyonson opened this issue Aug 10, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@nyonson
Copy link

nyonson commented Aug 10, 2021

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.

@nyonson nyonson added the bug Something isn't working label Aug 10, 2021
@jamaljsr
Copy link
Owner

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.

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.

@nyonson
Copy link
Author

nyonson commented Aug 11, 2021

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.

@jamaljsr
Copy link
Owner

Awesome! That would be very helpful. Thanks 🥇

@nyonson
Copy link
Author

nyonson commented Sep 8, 2021

I poked around about and believe this is the root of the issue: electron/electron#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.

@jamaljsr
Copy link
Owner

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.

@jamaljsr
Copy link
Owner

This was fixed in #695

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants