Skip to content

Commit 29770e2

Browse files
authored
Merge pull request #1022 from Baqend/issue-818-support-tmpfs
Issue 818 support tmpfs
2 parents 360adaa + 84eaebc commit 29770e2

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.io.Serializable;
1515
import java.util.Arrays;
1616
import java.util.List;
17+
import java.util.Map;
1718

1819
/**
1920
* Used in `/containers/create`, and in inspect container.
@@ -206,6 +207,12 @@ public class HostConfig implements Serializable {
206207
@JsonProperty("Runtime")
207208
private String runtime;
208209

210+
/**
211+
* @since ~{@link RemoteApiVersion#VERSION_1_22}
212+
*/
213+
@JsonProperty("Tmpfs")
214+
private Map<String, String> tmpFs;
215+
209216
@JsonIgnore
210217
public Bind[] getBinds() {
211218
return (binds == null) ? new Bind[0] : binds.getBinds();
@@ -434,6 +441,14 @@ public Long getPidsLimit() {
434441
return pidsLimit;
435442
}
436443

444+
/**
445+
* @see #tmpFs
446+
*/
447+
@CheckForNull
448+
public Map<String, String> getTmpFs() {
449+
return tmpFs;
450+
}
451+
437452
/**
438453
* Parse the network mode as specified at
439454
* {@see https://github.com/docker/engine-api/blob/master/types/container/hostconfig_unix.go}
@@ -830,6 +845,15 @@ public HostConfig withRuntime(String runtime) {
830845
this.runtime = runtime;
831846
return this;
832847
}
848+
849+
/**
850+
* @see #tmpFs
851+
*/
852+
public HostConfig withTmpFs(Map<String, String> tmpFs) {
853+
this.tmpFs = tmpFs;
854+
return this;
855+
}
856+
833857
// end of auto-generated
834858

835859
@Override

src/test/java/com/github/dockerjava/cmd/CreateContainerCmdIT.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import java.io.File;
4141
import java.security.SecureRandom;
4242
import java.util.Arrays;
43+
import java.util.Collections;
4344
import java.util.HashMap;
4445
import java.util.Map;
4546
import java.util.UUID;
@@ -866,4 +867,14 @@ public void createContainerFromPrivateRegistryWithNoAuth() throws Exception {
866867
.exec();
867868
}
868869

870+
@Test
871+
public void createContainerWithTmpFs() throws DockerException {
872+
CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE).withCmd("sleep", "9999")
873+
.withHostConfig(new HostConfig().withTmpFs(Collections.singletonMap("/tmp", "rw,noexec,nosuid,size=50m"))).exec();
874+
875+
assertThat(container.getId(), not(isEmptyString()));
876+
877+
InspectContainerResponse inspectContainerResponse = dockerRule.getClient().inspectContainerCmd(container.getId()).exec();
878+
assertThat(inspectContainerResponse.getHostConfig().getTmpFs().get("/tmp"), equalTo("rw,noexec,nosuid,size=50m"));
879+
}
869880
}

0 commit comments

Comments
 (0)