Skip to content

Commit 23ad597

Browse files
authored
do not store default properties in docker-java.properties file (#1311)
1 parent ffec4f5 commit 23ad597

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public class DefaultDockerClientConfig implements Serializable, DockerClientConf
5656

5757
private static final Set<String> CONFIG_KEYS = new HashSet<>();
5858

59+
private static final Properties DEFAULT_PROPERTIES = new Properties();
60+
5961
static {
6062
CONFIG_KEYS.add(DOCKER_HOST);
6163
CONFIG_KEYS.add(DOCKER_TLS_VERIFY);
@@ -66,6 +68,11 @@ public class DefaultDockerClientConfig implements Serializable, DockerClientConf
6668
CONFIG_KEYS.add(REGISTRY_PASSWORD);
6769
CONFIG_KEYS.add(REGISTRY_EMAIL);
6870
CONFIG_KEYS.add(REGISTRY_URL);
71+
72+
DEFAULT_PROPERTIES.put(DOCKER_HOST, "unix:///var/run/docker.sock");
73+
DEFAULT_PROPERTIES.put(DOCKER_CONFIG, "${user.home}/.docker");
74+
DEFAULT_PROPERTIES.put(REGISTRY_URL, "https://index.docker.io/v1/");
75+
DEFAULT_PROPERTIES.put(REGISTRY_USERNAME, "${user.name}");
6976
}
7077

7178
private final URI dockerHost;
@@ -100,14 +107,17 @@ private URI checkDockerHostScheme(URI dockerHost) {
100107
}
101108

102109
private static Properties loadIncludedDockerProperties(Properties systemProperties) {
110+
Properties p = new Properties();
111+
p.putAll(DEFAULT_PROPERTIES);
103112
try (InputStream is = DefaultDockerClientConfig.class.getResourceAsStream("/" + DOCKER_JAVA_PROPERTIES)) {
104-
Properties p = new Properties();
105-
p.load(is);
106-
replaceProperties(p, systemProperties);
107-
return p;
113+
if (is != null) {
114+
p.load(is);
115+
}
108116
} catch (IOException e) {
109117
throw new RuntimeException(e);
110118
}
119+
replaceProperties(p, systemProperties);
120+
return p;
111121
}
112122

113123
private static void replaceProperties(Properties properties, Properties replacements) {

docker-java/src/main/resources/docker-java.properties

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)