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

Handle when socket is in the home directory #345

Open
banool opened this issue Oct 24, 2023 · 5 comments
Open

Handle when socket is in the home directory #345

banool opened this issue Oct 24, 2023 · 5 comments
Labels
question Further information is requested

Comments

@banool
Copy link

banool commented Oct 24, 2023

Hey hey,

Currently when creating a Docker client like this:

Docker::connect_with_local_defaults

It looks for the socket at /var/run/docker.sock. The new default in Docker Desktop is to put the socket in your home dir instead, so new Docker users won't have the socket there, but at ~/.docker/run/docker.sock.

Would you accept a PR that makes the function look first for the socket at /var/run/docker.sock and then at ~/.docker/run/docker.sock?

Thanks!

@banool
Copy link
Author

banool commented Oct 24, 2023

This is how I'm handling this for now myself btw: aptos-labs/aptos-core#10654.

@fussybeaver
Copy link
Owner

I was looking to see if the official moby source does this, as I guess that's slightly different to Docker Desktop ? (which OS are you referring to?)

I didn't find anything in the moby source that there's a fallback, but I did see this line:
https://github.com/moby/moby/blob/d83ead84340ca8a586186a13d4d7169931593b5e/contrib/dockerd-rootless-setuptool.sh#L345

which suggests that one should set the DOCKER_HOST environment variable, which should also work in Bollard...

@banool
Copy link
Author

banool commented Oct 25, 2023

In my case I'm mostly referring to MacOS, but I suppose it might be relevant to Linux too. Just not Windows, since it's always just that same named pipe.

As for the DOCKER_HOST environment variable, it seems like Docker when installed doesn't configure this. The user could set this themselves but that's no better than just using the env var to tell Bollard where to find the Docker socket. What I'm sort of hoping for / planning here is to have Bollard try /var/run/docker.sock first and then if that's not there, try the one in the home dir. In other words ideally the default connect function on Bollard should just work out of the box with either socket location.

@fussybeaver
Copy link
Owner

Thanks, I noticed when looking more closely at this that there's a docker command docker context which we don't surface in Bollard... I'll need to take another look when I have some time.

In principal it sounds fine to have that fallback added, if you're interested in that.

@banool
Copy link
Author

banool commented Oct 26, 2023

Neato sounds good! I'll put this on my to do list.

@fussybeaver fussybeaver added the question Further information is requested label Dec 21, 2023
pms1969 added a commit to rustl3rs/banner that referenced this issue Feb 18, 2024
Retired and clearly had to give the work laptop back. So now working
on an old NUC running Arch. and there were a few things that didn't
quite work for me when starting, and that just created a whole bunch
of experimentation.  I've unwound everything but the essential
improvements.
* Updated Bollard; this was the crux of my problem and resulted in
                   quite a bit of code change, until I found this:
                   fussybeaver/bollard#345
* A typo or two.
* A clippy warning about unused import.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants