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

Add Docker Socket availability check during connection creation #383

Open
patrickap opened this issue Mar 7, 2024 · 3 comments
Open

Add Docker Socket availability check during connection creation #383

patrickap opened this issue Mar 7, 2024 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@patrickap
Copy link

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;
  }
};
@bpmooch
Copy link
Contributor

bpmooch commented Mar 9, 2024

As a workaround, I've been calling docker.ping() immediately after creating the connection

@fussybeaver
Copy link
Owner

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

@fussybeaver
Copy link
Owner

Can confirm, this is not a regression, happy if you can add this as a feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants