Skip to content

Commit 3ea46f9

Browse files
authored
Add Init attribute in ContainerSpec (#1927)
1 parent a961200 commit 3ea46f9

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ public class ContainerSpec extends DockerObject implements Serializable {
161161
@JsonProperty("Configs")
162162
private List<ContainerSpecConfig> configs;
163163

164+
/**
165+
* @since 1.38
166+
* Run an init inside the container that forwards signals and reaps processes.
167+
* This field is omitted if empty, and the default (as configured on the daemon) is used.
168+
*/
169+
@JsonProperty("Init")
170+
private Boolean init;
171+
164172
/**
165173
* @see #image
166174
*/
@@ -435,4 +443,13 @@ public ContainerSpec withConfigs(List<ContainerSpecConfig> configs) {
435443
this.configs = configs;
436444
return this;
437445
}
446+
447+
public Boolean getInit() {
448+
return init;
449+
}
450+
451+
public ContainerSpec withInit(Boolean init) {
452+
this.init = init;
453+
return this;
454+
}
438455
}

docker-java/src/test/java/com/github/dockerjava/cmd/swarm/UpdateSwarmServiceIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void testUpdateServiceReplicate() throws Exception {
2727
String networkId = dockerClient.createNetworkCmd().withName("networkname").withDriver("overlay")
2828
.withIpam(new Network.Ipam().withDriver("default")).exec().getId();
2929
TaskSpec taskSpec = new TaskSpec().withContainerSpec(
30-
new ContainerSpec().withImage("busybox").withArgs(Arrays.asList("sleep", "3600")));
30+
new ContainerSpec().withImage("busybox").withArgs(Arrays.asList("sleep", "3600")).withInit(true));
3131
ServiceSpec serviceSpec = new ServiceSpec()
3232
.withMode(new ServiceModeConfig().withReplicated(new ServiceReplicatedModeOptions().withReplicas(1)))
3333
.withTaskTemplate(taskSpec)

0 commit comments

Comments
 (0)