From 3cc4515d392e579f8f5293e051c7ddeda14f0498 Mon Sep 17 00:00:00 2001 From: Lucio Franco Date: Thu, 5 Dec 2019 22:42:44 -0500 Subject: Replace host str to use https if encrypted (#193) * Replace host str to use https if encrypted * Add comment and fmt --- src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index e8f9e95..f96915a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -885,6 +885,16 @@ fn get_docker_for_tcp(tcp_host_str: String) -> Docker { connector.set_ca_file(&Path::new(ca)).unwrap(); } + // If we are attempting to connec to the docker daemon via tcp + // we need to convert the scheme to `https` to let hyper connect. + // Otherwise, hyper will reject the connection since it does not + // recongnize `tcp` as a valid `http` scheme. + let tcp_host_str = if tcp_host_str.contains("tcp://") { + tcp_host_str.replace("tcp://", "https://") + } else { + tcp_host_str + }; + Docker { transport: Transport::EncryptedTcp { client: Client::builder() -- cgit v1.2.3