Skip to content
This repository was archived by the owner on Feb 9, 2026. It is now read-only.

Commit 2008c99

Browse files
Merge pull request #1 from docker-java/master
merge from base
2 parents b3be4fb + 15aa30e commit 2008c99

6 files changed

Lines changed: 261 additions & 9 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,23 @@ For secure tls (https) communication:
5151
DOCKER_CERT_PATH=/Users/marcus/.docker/machine/machines/docker-1.11.2
5252

5353
### Latest release version
54-
Supports a subset of the Docker Remote API [v1.23](https://github.com/docker/docker/blob/master/docs/reference/api/docker_remote_api_v1.23.md), Docker Server version 1.11.x
54+
Supports a subset of the Docker Remote API [v1.23](https://github.com/docker/docker/blob/master/docs/api/v1.23.md), Docker Server version 1.11.x
5555

5656
<dependency>
5757
<groupId>com.github.docker-java</groupId>
5858
<artifactId>docker-java</artifactId>
59-
<version>3.0.3</version>
59+
<version>3.0.6</version>
6060
</dependency>
6161

6262
### Latest development version
63-
Supports a subset of the Docker Remote API [v1.23](https://github.com/docker/docker/blob/master/docs/reference/api/docker_remote_api_v1.23.md), Docker Server version 1.11.x
63+
Supports a subset of the Docker Remote API [v1.23](https://github.com/docker/docker/blob/master/docs/api/v1.23.md), Docker Server version 1.11.x
6464

6565
You can find the latest development version including javadoc and source files on [Sonatypes OSS repository](https://oss.sonatype.org/content/groups/public/com/github/docker-java/docker-java/).
6666

6767
<dependency>
6868
<groupId>com.github.docker-java</groupId>
6969
<artifactId>docker-java</artifactId>
70-
<version>3.0.4-SNAPSHOT</version>
70+
<version>3.0.7-SNAPSHOT</version>
7171
</dependency>
7272

7373

src/main/java/com/github/dockerjava/api/model/Bind.java

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,48 @@ public class Bind implements Serializable {
1818

1919
private AccessMode accessMode;
2020

21+
/**
22+
* @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_23}
23+
*/
24+
private Boolean noCopy;
25+
2126
/**
2227
* @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_17}
2328
*/
2429
private SELContext secMode;
2530

31+
/**
32+
* @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_22}
33+
*/
34+
private PropagationMode propagationMode;
35+
2636
public Bind(String path, Volume volume) {
2737
this(path, volume, AccessMode.DEFAULT, SELContext.DEFAULT);
2838
}
2939

40+
public Bind(String path, Volume volume, Boolean noCopy) {
41+
this(path, volume, AccessMode.DEFAULT, SELContext.DEFAULT, noCopy);
42+
}
43+
3044
public Bind(String path, Volume volume, AccessMode accessMode) {
3145
this(path, volume, accessMode, SELContext.DEFAULT);
3246
}
3347

3448
public Bind(String path, Volume volume, AccessMode accessMode, SELContext secMode) {
49+
this(path, volume, accessMode, secMode, null);
50+
}
51+
52+
public Bind(String path, Volume volume, AccessMode accessMode, SELContext secMode, Boolean noCopy) {
53+
this(path, volume, accessMode, secMode, noCopy, PropagationMode.DEFAULT_MODE);
54+
}
55+
56+
public Bind(String path, Volume volume, AccessMode accessMode, SELContext secMode, Boolean noCopy, PropagationMode propagationMode) {
3557
this.path = path;
3658
this.volume = volume;
3759
this.accessMode = accessMode;
3860
this.secMode = secMode;
61+
this.noCopy = noCopy;
62+
this.propagationMode = propagationMode;
3963
}
4064

4165
public String getPath() {
@@ -54,6 +78,14 @@ public SELContext getSecMode() {
5478
return secMode;
5579
}
5680

81+
public Boolean getNoCopy() {
82+
return noCopy;
83+
}
84+
85+
public PropagationMode getPropagationMode() {
86+
return propagationMode;
87+
}
88+
5789
/**
5890
* Parses a bind mount specification to a {@link Bind}.
5991
*
@@ -74,15 +106,25 @@ public static Bind parse(String serialized) {
74106
String[] flags = parts[2].split(",");
75107
AccessMode accessMode = AccessMode.DEFAULT;
76108
SELContext seMode = SELContext.DEFAULT;
109+
Boolean nocopy = null;
110+
PropagationMode propagationMode = PropagationMode.DEFAULT_MODE;
77111
for (String p : flags) {
78112
if (p.length() == 2) {
79113
accessMode = AccessMode.valueOf(p.toLowerCase());
114+
} else if ("nocopy".equals(p)) {
115+
nocopy = true;
116+
} else if (PropagationMode.SHARED.toString().equals(p)) {
117+
propagationMode = PropagationMode.SHARED;
118+
} else if (PropagationMode.SLAVE.toString().equals(p)) {
119+
propagationMode = PropagationMode.SLAVE;
120+
} else if (PropagationMode.PRIVATE.toString().equals(p)) {
121+
propagationMode = PropagationMode.PRIVATE;
80122
} else {
81123
seMode = SELContext.fromString(p);
82124
}
83125
}
84126

85-
return new Bind(parts[0], new Volume(parts[1]), accessMode, seMode);
127+
return new Bind(parts[0], new Volume(parts[1]), accessMode, seMode, nocopy, propagationMode);
86128
}
87129
default: {
88130
throw new IllegalArgumentException();
@@ -102,6 +144,8 @@ public boolean equals(Object obj) {
102144
.append(volume, other.getVolume())
103145
.append(accessMode, other.getAccessMode())
104146
.append(secMode, other.getSecMode())
147+
.append(noCopy, other.getNoCopy())
148+
.append(propagationMode, other.getPropagationMode())
105149
.isEquals();
106150
} else {
107151
return super.equals(obj);
@@ -115,6 +159,8 @@ public int hashCode() {
115159
.append(volume)
116160
.append(accessMode)
117161
.append(secMode)
162+
.append(noCopy)
163+
.append(propagationMode)
118164
.toHashCode();
119165
}
120166

@@ -127,10 +173,12 @@ public int hashCode() {
127173
*/
128174
@Override
129175
public String toString() {
130-
return String.format("%s:%s:%s%s",
176+
return String.format("%s:%s:%s%s%s%s",
131177
path,
132178
volume.getPath(),
133179
accessMode.toString(),
134-
secMode != SELContext.none ? "," + secMode.toString() : "");
180+
secMode != SELContext.none ? "," + secMode.toString() : "",
181+
noCopy != null ? ",nocopy" : "",
182+
propagationMode != PropagationMode.DEFAULT_MODE ? "," + propagationMode.toString() : "");
135183
}
136184
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.github.dockerjava.api.model;
2+
3+
/**
4+
* The propagation mode of a file system or file: <code>shared</code>, <code>slave</code> or <code>private</code>.
5+
*
6+
* @see https://github.com/docker/docker/pull/17034
7+
* @since 1.22
8+
*/
9+
public enum PropagationMode {
10+
/** default */
11+
DEFAULT(""),
12+
13+
/** shared */
14+
SHARED("shared"),
15+
16+
/** slave */
17+
SLAVE("slave"),
18+
19+
/** private */
20+
PRIVATE("private");
21+
22+
/**
23+
* The default {@link PropagationMode}: {@link #DEFAULT}
24+
*/
25+
public static final PropagationMode DEFAULT_MODE = DEFAULT;
26+
27+
private String value;
28+
29+
PropagationMode(String v) {
30+
value = v;
31+
}
32+
33+
@Override
34+
public String toString() {
35+
return value;
36+
}
37+
38+
public static PropagationMode fromString(String v) {
39+
switch (v) {
40+
case "shared":
41+
return SHARED;
42+
case "slave":
43+
return SLAVE;
44+
case "private":
45+
return PRIVATE;
46+
default:
47+
return DEFAULT;
48+
}
49+
}
50+
}

src/main/java/com/github/dockerjava/netty/NettyDockerCmdExecFactory.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@
108108
import com.github.dockerjava.netty.exec.RenameContainerCmdExec;
109109

110110
import io.netty.bootstrap.Bootstrap;
111+
import io.netty.channel.Channel;
112+
import io.netty.channel.ChannelConfig;
113+
import io.netty.channel.ChannelFactory;
111114
import io.netty.channel.ChannelInitializer;
112115
import io.netty.channel.EventLoopGroup;
113116
import io.netty.channel.epoll.EpollDomainSocketChannel;
@@ -178,6 +181,8 @@ public DuplexChannel getChannel() {
178181
}
179182
};
180183

184+
private Integer connectTimeout = null;
185+
181186
@Override
182187
public void init(DockerClientConfig dockerClientConfig) {
183188
checkNotNull(dockerClientConfig, "config was not specified");
@@ -218,7 +223,15 @@ private class UnixDomainSocketInitializer implements NettyInitializer {
218223
@Override
219224
public EventLoopGroup init(Bootstrap bootstrap, DockerClientConfig dockerClientConfig) {
220225
EventLoopGroup epollEventLoopGroup = new EpollEventLoopGroup(0, new DefaultThreadFactory(threadPrefix));
221-
bootstrap.group(epollEventLoopGroup).channel(EpollDomainSocketChannel.class)
226+
227+
ChannelFactory<EpollDomainSocketChannel> factory = new ChannelFactory<EpollDomainSocketChannel>() {
228+
@Override
229+
public EpollDomainSocketChannel newChannel() {
230+
return configure(new EpollDomainSocketChannel());
231+
}
232+
};
233+
234+
bootstrap.group(epollEventLoopGroup).channelFactory(factory)
222235
.handler(new ChannelInitializer<UnixChannel>() {
223236
@Override
224237
protected void initChannel(final UnixChannel channel) throws Exception {
@@ -245,7 +258,14 @@ public EventLoopGroup init(Bootstrap bootstrap, final DockerClientConfig dockerC
245258

246259
Security.addProvider(new BouncyCastleProvider());
247260

248-
bootstrap.group(nioEventLoopGroup).channel(NioSocketChannel.class)
261+
ChannelFactory<NioSocketChannel> factory = new ChannelFactory<NioSocketChannel>() {
262+
@Override
263+
public NioSocketChannel newChannel() {
264+
return configure(new NioSocketChannel());
265+
}
266+
};
267+
268+
bootstrap.group(nioEventLoopGroup).channelFactory(factory)
249269
.handler(new ChannelInitializer<SocketChannel>() {
250270
@Override
251271
protected void initChannel(final SocketChannel channel) throws Exception {
@@ -580,6 +600,24 @@ public void close() throws IOException {
580600
eventLoopGroup.shutdownGracefully();
581601
}
582602

603+
/**
604+
* Configure connection timeout in milliseconds
605+
*/
606+
public NettyDockerCmdExecFactory withConnectTimeout(Integer connectTimeout) {
607+
this.connectTimeout = connectTimeout;
608+
return this;
609+
}
610+
611+
private <T extends Channel> T configure(T channel) {
612+
ChannelConfig channelConfig = channel.config();
613+
614+
if (connectTimeout != null) {
615+
channelConfig.setConnectTimeoutMillis(connectTimeout);
616+
}
617+
618+
return channel;
619+
}
620+
583621
private WebTarget getBaseResource() {
584622
return new WebTarget(channelProvider);
585623
}

0 commit comments

Comments
 (0)