GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge branch 'master' into master · ConnorLinfoot/docker-java@dd570e8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • docker-java-api/src/main/java/com/github/dockerjava/api
    • DockerClientDelegate.java
    • model
      • LogConfig.java
      • PropagationMode.java
  • docker-java-bom
    • pom.xml
  • docker-java-core/src/main/java/com/github/dockerjava/core
    • DefaultDockerClientConfig.java
  • docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5
    • ApacheDockerHttpClientImpl.java
  • docker-java-transport-okhttp/src/main/java/com/github/dockerjava/okhttp
    • UnixSocketFactory.java
  • docker-java-transport/src/main/java/com/github/dockerjava/transport
    • DomainSocket.java
    • UnixSocket.java
  • docker-java/src/test/java/com/github/dockerjava
    • cmd
      • CustomCommandIT.java
    • core
      • DefaultDockerClientConfigTest.java
      • DockerClientDelegate.java
      • DockerRule.java
  • pom.xml
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docker-java-api/src/main/java/com/github/dockerjava/api/DockerClientDelegate.java‎

Copy file name to clipboardExpand all lines: docker-java-api/src/main/java/com/github/dockerjava/api/DockerClientDelegate.java
+515Lines changed: 515 additions & 0 deletions
Large diffs are not rendered by default.
Collapse file

‎docker-java-api/src/main/java/com/github/dockerjava/api/model/LogConfig.java‎

Copy file name to clipboardExpand all lines: docker-java-api/src/main/java/com/github/dockerjava/api/model/LogConfig.java
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ public enum LoggingType {
7676
AWSLOGS("awslogs"),
7777
DB("db"), // Synology specific driver
7878
SPLUNK("splunk"),
79-
GCPLOGS("gcplogs");
79+
GCPLOGS("gcplogs"),
80+
LOKI("loki");
8081

8182
private String type;
8283

Collapse file

‎docker-java-api/src/main/java/com/github/dockerjava/api/model/PropagationMode.java‎

Copy file name to clipboardExpand all lines: docker-java-api/src/main/java/com/github/dockerjava/api/model/PropagationMode.java
+16-1Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,20 @@ public enum PropagationMode {
1313
/** shared */
1414
SHARED("shared"),
1515

16+
/** rshared */
17+
RSHARED("rshared"),
18+
1619
/** slave */
1720
SLAVE("slave"),
1821

22+
/** rslave */
23+
RSLAVE("rslave"),
24+
1925
/** private */
20-
PRIVATE("private");
26+
PRIVATE("private"),
27+
28+
/** rprivate */
29+
RPRIVATE("rprivate");
2130

2231
/**
2332
* The default {@link PropagationMode}: {@link #DEFAULT}
@@ -39,10 +48,16 @@ public static PropagationMode fromString(String v) {
3948
switch (v) {
4049
case "shared":
4150
return SHARED;
51+
case "rshared":
52+
return RSHARED;
4253
case "slave":
4354
return SLAVE;
55+
case "rslave":
56+
return RSLAVE;
4457
case "private":
4558
return PRIVATE;
59+
case "rprivate":
60+
return RPRIVATE;
4661
default:
4762
return DEFAULT;
4863
}
Collapse file

‎docker-java-bom/pom.xml‎

Copy file name to clipboard
+67Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
4+
<parent>
5+
<groupId>com.github.docker-java</groupId>
6+
<artifactId>docker-java-parent</artifactId>
7+
<version>0-SNAPSHOT</version>
8+
<relativePath>../pom.xml</relativePath>
9+
</parent>
10+
11+
<artifactId>docker-java-bom</artifactId>
12+
<packaging>pom</packaging>
13+
14+
<name>docker-java</name>
15+
<url>https://github.com/docker-java/docker-java</url>
16+
<description>Java API Client for Docker</description>
17+
18+
<dependencyManagement>
19+
<dependencies>
20+
<dependency>
21+
<groupId>${project.groupId}</groupId>
22+
<artifactId>docker-java</artifactId>
23+
<version>${project.version}</version>
24+
</dependency>
25+
<dependency>
26+
<groupId>${project.groupId}</groupId>
27+
<artifactId>docker-java-api</artifactId>
28+
<version>${project.version}</version>
29+
</dependency>
30+
<dependency>
31+
<groupId>${project.groupId}</groupId>
32+
<artifactId>docker-java-core</artifactId>
33+
<version>${project.version}</version>
34+
</dependency>
35+
<dependency>
36+
<groupId>${project.groupId}</groupId>
37+
<artifactId>docker-java-transport</artifactId>
38+
<version>${project.version}</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>${project.groupId}</groupId>
42+
<artifactId>docker-java-transport-httpclient5</artifactId>
43+
<version>${project.version}</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>${project.groupId}</groupId>
47+
<artifactId>docker-java-transport-jersey</artifactId>
48+
<version>${project.version}</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>${project.groupId}</groupId>
52+
<artifactId>docker-java-transport-netty</artifactId>
53+
<version>${project.version}</version>
54+
</dependency>
55+
<dependency>
56+
<groupId>${project.groupId}</groupId>
57+
<artifactId>docker-java-transport-okhttp</artifactId>
58+
<version>${project.version}</version>
59+
</dependency>
60+
<dependency>
61+
<groupId>${project.groupId}</groupId>
62+
<artifactId>docker-java-transport-zerodep</artifactId>
63+
<version>${project.version}</version>
64+
</dependency>
65+
</dependencies>
66+
</dependencyManagement>
67+
</project>
Collapse file

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

Copy file name to clipboardExpand all lines: docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java
+20-4Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.github.dockerjava.core.NameParser.HostnameReposName;
77
import com.github.dockerjava.core.NameParser.ReposTag;
88
import org.apache.commons.lang.StringUtils;
9+
import org.apache.commons.lang.SystemUtils;
910
import org.apache.commons.lang.builder.EqualsBuilder;
1011
import org.apache.commons.lang.builder.HashCodeBuilder;
1112
import org.apache.commons.lang.builder.ToStringBuilder;
@@ -58,6 +59,10 @@ public class DefaultDockerClientConfig implements Serializable, DockerClientConf
5859

5960
static final Properties DEFAULT_PROPERTIES = new Properties();
6061

62+
static final String DEFAULT_DOCKER_HOST = "unix:///var/run/docker.sock";
63+
64+
static final String WINDOWS_DEFAULT_DOCKER_HOST = "npipe:////./pipe/docker_engine";
65+
6166
static {
6267
CONFIG_KEYS.add(DOCKER_HOST);
6368
CONFIG_KEYS.add(DOCKER_TLS_VERIFY);
@@ -69,7 +74,6 @@ public class DefaultDockerClientConfig implements Serializable, DockerClientConf
6974
CONFIG_KEYS.add(REGISTRY_EMAIL);
7075
CONFIG_KEYS.add(REGISTRY_URL);
7176

72-
DEFAULT_PROPERTIES.put(DOCKER_HOST, "unix:///var/run/docker.sock");
7377
DEFAULT_PROPERTIES.put(DOCKER_CONFIG, "${user.home}/.docker");
7478
DEFAULT_PROPERTIES.put(REGISTRY_URL, "https://index.docker.io/v1/");
7579
DEFAULT_PROPERTIES.put(REGISTRY_USERNAME, "${user.name}");
@@ -337,8 +341,12 @@ public static class Builder {
337341
* registry.email, DOCKER_CERT_PATH, and DOCKER_CONFIG.
338342
*/
339343
public Builder withProperties(Properties p) {
340-
return withDockerHost(p.getProperty(DOCKER_HOST))
341-
.withDockerTlsVerify(p.getProperty(DOCKER_TLS_VERIFY))
344+
345+
if (p.getProperty(DOCKER_HOST) != null) {
346+
withDockerHost(p.getProperty(DOCKER_HOST));
347+
}
348+
349+
return withDockerTlsVerify(p.getProperty(DOCKER_TLS_VERIFY))
342350
.withDockerConfig(p.getProperty(DOCKER_CONFIG))
343351
.withDockerCertPath(p.getProperty(DOCKER_CERT_PATH))
344352
.withApiVersion(p.getProperty(API_VERSION))
@@ -412,6 +420,10 @@ public final Builder withDockerTlsVerify(Boolean dockerTlsVerify) {
412420
return this;
413421
}
414422

423+
public final boolean isDockerHostSetExplicitly() {
424+
return dockerHost != null;
425+
}
426+
415427
/**
416428
* Overrides the default {@link SSLConfig} that is used when calling {@link Builder#withDockerTlsVerify(java.lang.Boolean)} and
417429
* {@link Builder#withDockerCertPath(String)}. This way it is possible to pass a custom {@link SSLConfig} to the resulting
@@ -435,7 +447,11 @@ public DefaultDockerClientConfig build() {
435447
sslConfig = customSslConfig;
436448
}
437449

438-
return new DefaultDockerClientConfig(dockerHost, dockerConfig, apiVersion, registryUrl, registryUsername,
450+
URI dockerHostUri = dockerHost != null
451+
? dockerHost
452+
: URI.create(SystemUtils.IS_OS_WINDOWS ? WINDOWS_DEFAULT_DOCKER_HOST : DEFAULT_DOCKER_HOST);
453+
454+
return new DefaultDockerClientConfig(dockerHostUri, dockerConfig, apiVersion, registryUrl, registryUsername,
439455
registryPassword, registryEmail, sslConfig);
440456
}
441457

Collapse file

‎docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/ApacheDockerHttpClientImpl.java‎

Copy file name to clipboardExpand all lines: docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/ApacheDockerHttpClientImpl.java
+12-2Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.github.dockerjava.httpclient5;
22

33
import com.github.dockerjava.transport.DockerHttpClient;
4-
import com.github.dockerjava.transport.DomainSocket;
54
import com.github.dockerjava.transport.NamedPipeSocket;
65
import com.github.dockerjava.transport.SSLConfig;
6+
import com.github.dockerjava.transport.UnixSocket;
77
import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
88
import org.apache.hc.client5.http.config.RequestConfig;
99
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
@@ -24,11 +24,14 @@
2424
import org.apache.hc.core5.http.config.RegistryBuilder;
2525
import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy;
2626
import org.apache.hc.core5.http.impl.io.EmptyInputStream;
27+
import org.apache.hc.core5.http.io.SocketConfig;
2728
import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
2829
import org.apache.hc.core5.http.io.entity.InputStreamEntity;
2930
import org.apache.hc.core5.http.protocol.BasicHttpContext;
3031
import org.apache.hc.core5.http.protocol.HttpContext;
3132
import org.apache.hc.core5.net.URIAuthority;
33+
import org.apache.hc.core5.util.TimeValue;
34+
import org.apache.hc.core5.util.Timeout;
3235
import org.slf4j.Logger;
3336
import org.slf4j.LoggerFactory;
3437

@@ -93,6 +96,13 @@ protected ApacheDockerHttpClientImpl(
9396
null
9497
)
9598
);
99+
// See https://github.com/docker-java/docker-java/pull/1590#issuecomment-870581289
100+
connectionManager.setDefaultSocketConfig(
101+
SocketConfig.copy(SocketConfig.DEFAULT)
102+
.setSoTimeout(Timeout.ZERO_MILLISECONDS)
103+
.build()
104+
);
105+
connectionManager.setValidateAfterInactivity(TimeValue.NEG_ONE_SECOND);
96106
connectionManager.setMaxTotal(maxConnections);
97107
connectionManager.setDefaultMaxPerRoute(maxConnections);
98108
RequestConfig.Builder defaultRequest = RequestConfig.custom();
@@ -134,7 +144,7 @@ private Registry<ConnectionSocketFactory> createConnectionSocketFactoryRegistry(
134144
.register("unix", new PlainConnectionSocketFactory() {
135145
@Override
136146
public Socket createSocket(HttpContext context) throws IOException {
137-
return DomainSocket.get(dockerHost.getPath());
147+
return UnixSocket.get(dockerHost.getPath());
138148
}
139149
})
140150
.register("npipe", new PlainConnectionSocketFactory() {
Collapse file

‎docker-java-transport-okhttp/src/main/java/com/github/dockerjava/okhttp/UnixSocketFactory.java‎

Copy file name to clipboardExpand all lines: docker-java-transport-okhttp/src/main/java/com/github/dockerjava/okhttp/UnixSocketFactory.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.github.dockerjava.okhttp;
22

3-
import com.github.dockerjava.transport.DomainSocket;
3+
import com.github.dockerjava.transport.UnixSocket;
44

55
import javax.net.SocketFactory;
66
import java.io.IOException;
@@ -18,7 +18,7 @@ class UnixSocketFactory extends SocketFactory {
1818
@Override
1919
public Socket createSocket() {
2020
try {
21-
return DomainSocket.get(socketPath);
21+
return UnixSocket.get(socketPath);
2222
} catch (IOException e) {
2323
throw new RuntimeException(e);
2424
}
Collapse file

‎docker-java-transport/src/main/java/com/github/dockerjava/transport/DomainSocket.java‎

Copy file name to clipboardExpand all lines: docker-java-transport/src/main/java/com/github/dockerjava/transport/DomainSocket.java
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ public void close() throws IOException {
130130
* @param path the path to the domain socket
131131
* @return a {@link DomainSocket} instance
132132
* @throws IOException if the socket cannot be opened
133+
* @deprecated use {@link UnixSocket#get(String)}
133134
*/
135+
@Deprecated
134136
public static DomainSocket get(String path) throws IOException {
135137
if (Platform.isMac() || isBsdPlatform()) {
136138
return new BsdDomainSocket(path);
Collapse file

‎docker-java-transport/src/main/java/com/github/dockerjava/transport/UnixSocket.java‎

Copy file name to clipboard
+88Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package com.github.dockerjava.transport;
2+
3+
import java.io.IOException;
4+
import java.io.InputStream;
5+
import java.io.OutputStream;
6+
import java.net.Socket;
7+
import java.net.SocketAddress;
8+
import java.net.SocketException;
9+
import java.nio.channels.Channels;
10+
import java.nio.channels.SocketChannel;
11+
12+
public class UnixSocket extends AbstractSocket {
13+
14+
/**
15+
* Return a new {@link Socket} for the given path. Will use JDK's {@link java.net.UnixDomainSocketAddress}
16+
* if available and fallback to {@link DomainSocket} otherwise.
17+
*
18+
* @param path the path to the domain socket
19+
* @return a {@link Socket} instance
20+
* @throws IOException if the socket cannot be opened
21+
*/
22+
public static Socket get(String path) throws IOException {
23+
try {
24+
return new UnixSocket(path);
25+
} catch (Exception e) {
26+
//noinspection deprecation
27+
return DomainSocket.get(path);
28+
}
29+
}
30+
31+
private final SocketAddress socketAddress;
32+
33+
private final SocketChannel socketChannel;
34+
35+
private UnixSocket(String path) throws Exception {
36+
Class<?> unixDomainSocketAddress = Class.forName("java.net.UnixDomainSocketAddress");
37+
this.socketAddress =
38+
(SocketAddress) unixDomainSocketAddress.getMethod("of", String.class)
39+
.invoke(null, path);
40+
this.socketChannel = SocketChannel.open(this.socketAddress);
41+
}
42+
43+
@Override
44+
public InputStream getInputStream() throws IOException {
45+
if (isClosed()) {
46+
throw new SocketException("Socket is closed");
47+
}
48+
if (!isConnected()) {
49+
throw new SocketException("Socket is not connected");
50+
}
51+
if (isInputShutdown()) {
52+
throw new SocketException("Socket input is shutdown");
53+
}
54+
55+
return Channels.newInputStream(socketChannel);
56+
}
57+
58+
@Override
59+
public OutputStream getOutputStream() throws IOException {
60+
if (isClosed()) {
61+
throw new SocketException("Socket is closed");
62+
}
63+
if (!isConnected()) {
64+
throw new SocketException("Socket is not connected");
65+
}
66+
if (isOutputShutdown()) {
67+
throw new SocketException("Socket output is shutdown");
68+
}
69+
70+
return Channels.newOutputStream(socketChannel);
71+
}
72+
73+
@Override
74+
public SocketAddress getLocalSocketAddress() {
75+
return socketAddress;
76+
}
77+
78+
@Override
79+
public SocketAddress getRemoteSocketAddress() {
80+
return socketAddress;
81+
}
82+
83+
@Override
84+
public void close() throws IOException {
85+
super.close();
86+
this.socketChannel.close();
87+
}
88+
}
Collapse file

‎docker-java/src/test/java/com/github/dockerjava/cmd/CustomCommandIT.java‎

Copy file name to clipboardExpand all lines: docker-java/src/test/java/com/github/dockerjava/cmd/CustomCommandIT.java
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.dockerjava.cmd;
22

33
import com.github.dockerjava.core.DockerClientImpl;
4+
import com.github.dockerjava.core.DockerRule;
45
import com.github.dockerjava.transport.DockerHttpClient;
56
import com.github.dockerjava.transport.DockerHttpClient.Request;
67
import com.github.dockerjava.transport.DockerHttpClient.Response;
@@ -17,7 +18,8 @@ public class CustomCommandIT extends CmdIT {
1718

1819
@Test
1920
public void testCustomCommand() throws Exception {
20-
DockerHttpClient httpClient = ((DockerClientImpl) dockerRule.getClient()).getHttpClient();
21+
DockerClientImpl dockerClient = getFactoryType().createDockerClient(DockerRule.config(null));
22+
DockerHttpClient httpClient = dockerClient.getHttpClient();
2123

2224
Assume.assumeNotNull(httpClient);
2325

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.