Add Docker Socket availability check during connection creation
patrickap opened this issue · comments
Currently, the connect_with_
methods return a type of Result<Docker, Error>
without performing any availability check. This means that even if the Docker Socket is not available, the method returns Ok()
instead of Err()
.
For example, when attempting to connect using Docker::connect_with_socket_defaults()
, if /var/run/docker.sock
is not available, it still returns Ok()
instead of Err()
.
To improve usability and prevent unexpected behavior, I propose adding an availability check during connection creation. This check should verify the availability of the Docker Socket and return an error if it's not accessible.
let docker = match Docker::connect_with_socket_defaults() {
Ok(docker) => docker,
Err(err) => {
eprintln!("failed to connect to docker daemon: {:?}", err);
return;
}
};
As a workaround, I've been calling docker.ping()
immediately after creating the connection
Hmm.. thanks for reporting, let's check first that this isn't a regression from the previous version, because quite a lot changed with the hyper 1.x upgrade
Can confirm, this is not a regression, happy if you can add this as a feature