summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Wood <in@davidtw.co>2018-11-14 05:31:55 +0000
committerdoug tangren <d.tangren@gmail.com>2018-11-14 14:31:55 +0900
commit29bd95b42cd2b3c364f0be1f3e07e4b654e0ccf3 (patch)
treebff64b2161175b80af7c4d8fd496123eb7ccf3d8 /src
parent75123f82a6f350299f1e9fc74d73dd4406a01cdc (diff)
Disable Hyper's http protocol enforcement. (#129)
There are some situations where the Docker daemon will expose a HTTP server and will expect connections through a TCP connection rather than via a unix socket. For example, this is the case with Docker for Windows when used through the Windows Subsystem for Linux. In these cases, `DOCKER_HOST` will be of the form `tcp://127.0.0.1:2375`. Docker will not work if `DOCKER_HOST` has the `http` protocol. This commit manually builds a `HttpConnector` from Hyper so that it does not fail if the protocol is not `http`. Therefore, the `DOCKER_HOST` that works with Docker will also work with shiplift.
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index fd45911..6823ea3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -729,6 +729,10 @@ impl Docker {
Some("unix") => panic!("Unix socket support is disabled"),
_ => {
+ let mut http = HttpConnector::new(1);
+ // Required to support DOCKER_HOST variables of the form `tcp://127.0.0.1:2375`.
+ http.enforce_http(false);
+
if let Ok(ref certs) = env::var("DOCKER_CERT_PATH") {
// fixme: don't unwrap before you know what's in the box
// https://github.com/hyperium/hyper/blob/master/src/net.rs#L427-L428
@@ -747,12 +751,10 @@ impl Docker {
connector.set_ca_file(&Path::new(ca)).unwrap();
}
- let http = HttpConnector::new(1);
- let connector = HttpsConnector::with_connector(http, connector).unwrap();
-
Docker {
transport: Transport::EncryptedTcp {
- client: Client::builder().build(connector),
+ client: Client::builder()
+ .build(HttpsConnector::with_connector(http, connector).unwrap()),
runtime: RefCell::new(tokio::runtime::Runtime::new().unwrap()),
host: tcp_host_str,
},
@@ -760,7 +762,7 @@ impl Docker {
} else {
Docker {
transport: Transport::Tcp {
- client: Client::new(),
+ client: Client::builder().build(http),
runtime: RefCell::new(tokio::runtime::Runtime::new().unwrap()),
host: tcp_host_str,
},