fussybeaver / bollard

Docker daemon API in Rust
Apache License 2.0
814 stars 127 forks source link

fix: improve socket error handling #414

Closed KMJ-007 closed 3 weeks ago

KMJ-007 commented 1 month ago

I am new to rust, I was building docker tui, and came across the same issue as #383, i tried to fix this,

I don't know what other things I need to fix or add, this is going to be my 1st PR for rust, so if any issues need to be addressed please let me know,

closes #383

had this question:

thankyou for creating this lib, it is helping me a lot!!

fussybeaver commented 1 month ago

Thanks for this... could you also check if the socket is readable? I recall that some linux distributions require group access to the socket.

KMJ-007 commented 1 month ago

Thanks for this... could you also check if the socket is readable? I recall that some linux distributions require group access to the socket.

i have mac, in that it is working, not asking for any permission, don't have linux machine at the moment

image
KMJ-007 commented 4 weeks ago

@fussybeaver , i got my friend's linux pc, and tested it

it is working, not asking for any permission

image

KMJ-007 commented 4 weeks ago

it is running pop os

@fussybeaver , i got my friend's linux pc, and tested it

it is working, not asking for any permission

image

KMJ-007 commented 4 weeks ago

let me know what is show stopper for this PR, and what i can improve?

KMJ-007 commented 4 weeks ago

All ci/cd's are green except docs one, i tried to check the logs but didn't understand why it is falling

fussybeaver commented 4 weeks ago

It looks like a doctest is failing, try adding a ,no_run pragma to this line https://github.com/fussybeaver/bollard/blob/9435d91ef9d9d30cd95d85b3bcca9aba4b6a4e8e/src/grpc/driver/docker_container.rs#L121

KMJ-007 commented 4 weeks ago

now something new is failing

KMJ-007 commented 4 weeks ago

@fussybeaver All Green

mominul commented 3 weeks ago

@fussybeaver Hi, can you kindly release a patch version of this crate with this change? I am facing this HyperLegacyError.

called `Result::unwrap()` on an `Err` value: Client(CreateContainer(HyperLegacyError { err: Error { kind: Connect, source: Some(Os { code: 2, kind: NotFound, message: "No such file or directory" }) } }))

I am using testcontainers_modules crate which in turn uses bollard on macOS with Docker version 26.1.1, build 4cf5afa. Although docker is running I am getting this error. I got referenced to #399 from a google search. It might help me to troubleshoot this error if this change is available in the new release.

mominul commented 3 weeks ago

After patching the bollard dependency in Cargo.toml

[patch.crates-io]
bollard = { git = "https://github.com/fussybeaver/bollard.git" }

The error I get is:

Failed to start container: failed to initialize a docker client: Socket not found: /var/run/docker.sock

After enabling the Allow privileged port mapping option, now bollard is able to connect with docker successfully. :tada:

image

I solved this by following the lando/lando#3533 thread. But following the testcontainers/testcontainers-java#6045 and lando/lando#3533 threads, it seems that in macOS docker desktop opens the docker.sock at ~/.docker/run/docker.sock and /var/run/docker.sock is a symlink to it:

$ ll /var/run/docker.sock 
lrwxr-xr-x@ 1 root  daemon    38B Jul  9 23:55 /var/run/docker.sock@ -> /Users/mominul/.docker/run/docker.sock

So on macOS, ~/.docker/run/docker.sock should be a fallback option, otherwise the users would need to face issues like I have faced.

Thank you for this crate! ❤️