Skip to content
This repository was archived by the owner on Mar 21, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
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
28 changes: 24 additions & 4 deletions src/main/java/com/spotify/docker/client/messages/HostConfig.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public class HostConfig {
private Boolean autoRemove;
@JsonProperty("PidsLimit")
private Integer pidsLimit;
@JsonProperty("ReadonlyRootfs")
private Boolean readonlyRootfs;

private HostConfig() {
}
Expand Down Expand Up @@ -141,6 +143,7 @@ private HostConfig(final Builder builder) {
this.oomScoreAdj = builder.oomScoreAdj;
this.autoRemove = builder.autoRemove;
this.pidsLimit = builder.pidsLimit;
this.readonlyRootfs = builder.readonlyRootfs;
}

public List<String> binds() {
Expand Down Expand Up @@ -270,7 +273,11 @@ public Integer oomScoreAdj() {
public Integer pidsLimit() {
return pidsLimit;
}


public Boolean readonlyRootfs() {
return readonlyRootfs;
}

public Boolean autoRemove() {
return autoRemove;
}
Expand Down Expand Up @@ -316,7 +323,8 @@ public boolean equals(final Object o) {
Objects.equals(this.oomKillDisable, that.oomKillDisable) &&
Objects.equals(this.oomScoreAdj, that.oomScoreAdj) &&
Objects.equals(this.autoRemove, that.autoRemove) &&
Objects.equals(this.pidsLimit, that.pidsLimit);
Objects.equals(this.pidsLimit, that.pidsLimit) &&
Objects.equals(this.readonlyRootfs, that.readonlyRootfs);
}

@Override
Expand All @@ -326,7 +334,7 @@ public int hashCode() {
capDrop, networkMode, securityOpt, devices, memory, memorySwap,
memoryReservation, cpuShares, cpusetCpus, cpuQuota, cgroupParent,
restartPolicy, logConfig, ipcMode, ulimits, pidMode, shmSize,
oomKillDisable, oomScoreAdj, autoRemove, pidsLimit);
oomKillDisable, oomScoreAdj, autoRemove, pidsLimit, readonlyRootfs);
}

@Override
Expand Down Expand Up @@ -365,6 +373,7 @@ public String toString() {
.add("oomScoreAdj", oomScoreAdj)
.add("autoRemove", autoRemove)
.add("pidsLimit", pidsLimit)
.add("readonlyRootfs", readonlyRootfs)
.toString();
}

Expand Down Expand Up @@ -525,6 +534,7 @@ public static class Builder {
private Integer oomScoreAdj;
private Boolean autoRemove;
private Integer pidsLimit;
private Boolean readonlyRootfs;

private Builder() {
}
Expand Down Expand Up @@ -563,6 +573,7 @@ private Builder(final HostConfig hostConfig) {
this.oomScoreAdj = hostConfig.oomScoreAdj;
this.autoRemove = hostConfig.autoRemove;
this.pidsLimit = hostConfig.pidsLimit;
this.readonlyRootfs = hostConfig.readonlyRootfs;
}

/**
Expand Down Expand Up @@ -1086,9 +1097,18 @@ public Builder pidsLimit(final Integer pidsLimit) {
}

public Integer pidsLimit() {
return pidsLimit;
return pidsLimit;
}

public Builder readonlyRootfs(final Boolean readonlyRootfs) {
this.readonlyRootfs = readonlyRootfs;
return this;
}

public Boolean readonlyRootfs() {
return readonlyRootfs;
}

public HostConfig build() {
return new HostConfig(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3381,6 +3381,26 @@ public void testPidsLimit() throws Exception {

assertThat(info.hostConfig().pidsLimit(), is(100));
}

@Test
public void testReadonlyRootfs() throws Exception {
requireDockerApiVersionAtLeast("1.22", "ReadonlyRootfs");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// Pull image
sut.pull(BUSYBOX_LATEST);

final ContainerConfig config = ContainerConfig.builder()
.image(BUSYBOX_LATEST)
.hostConfig(HostConfig.builder()
.readonlyRootfs(true) // Defaults to -1
.build())
.build();

final ContainerCreation container = sut.createContainer(config, randomName());
final ContainerInfo info = sut.inspectContainer(container.id());

assertThat(info.hostConfig().readonlyRootfs(), is(true));
}

@Test(expected = ContainerNotFoundException.class)
public void testAutoRemoveWhenSetToTrue() throws Exception {
Expand Down