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

Fall back to unix socket on Linux if DOCKER_HOST is malformed #454

Merged
1 commit merged into from
Feb 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ protected static URI dockerDaemonUri(final boolean isLinux, @NotNull final Map<S
try {
userURI = new URI(host);
} catch (URISyntaxException e) {
LOG.error(String.format("Unable to parse %s property with value %s", DOCKER_HOST_PROPERTY, host), e);
LOG.error(String.format("Unable to parse environment variable %s with the following value - %s", DOCKER_HOST_PROPERTY, host), e);
// unable to use given property, fallback to default URL
return DEFAULT_DOCKER_MACHINE_URI;
return isLinux ? UNIX_SOCKET_URI : DEFAULT_DOCKER_MACHINE_URI;
}

// Secure connection ?
Expand All @@ -225,16 +225,16 @@ protected static URI dockerDaemonUri(final boolean isLinux, @NotNull final Map<S
try {
return new URI(protocol, null, userURI.getHost(), userURI.getPort(), null, null, null);
} catch (URISyntaxException e) {
LOG.error(String.format("Unable to create URI %s property with value %s and TLS %s", DOCKER_HOST_PROPERTY, host,
DOCKER_TLS_VERIFY_PROPERTY), e);
LOG.error(String.format("Unable to create URI from %s environment variable with value %s " +
"and TLS environment variable %s with value %s",
DOCKER_HOST_PROPERTY, host, DOCKER_TLS_VERIFY_PROPERTY, tls),
e);
// unable to use given property, fallback to default URL
return DEFAULT_DOCKER_MACHINE_URI;
}
} else if (isLinux) {
return UNIX_SOCKET_URI;
} else {
return DEFAULT_DOCKER_MACHINE_URI;
}

return isLinux ? UNIX_SOCKET_URI : DEFAULT_DOCKER_MACHINE_URI;
}

/**
Expand Down