Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ public interface CreateContainerCmd extends SyncDockerCmd<CreateContainerRespons
@CheckForNull
Long getMemorySwap();

@CheckForNull
Integer getMemorySwappiness();

@CheckForNull
String getName();

Expand Down Expand Up @@ -368,6 +371,8 @@ public interface CreateContainerCmd extends SyncDockerCmd<CreateContainerRespons

CreateContainerCmd withMemorySwap(Long memorySwap);

CreateContainerCmd withMemorySwappiness(Integer memorySwappiness);

CreateContainerCmd withName(String name);

CreateContainerCmd withNetworkDisabled(Boolean disableNetwork);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,12 @@ public Long getMemorySwap() {
return hostConfig.getMemorySwap();
}

@Override
@JsonIgnore
public Integer getMemorySwappiness() {
return hostConfig.getMemorySwappiness();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please don't proxy calls, use get/set directly on hostconfig

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

}

@Override
public String getName() {
return name;
Expand Down Expand Up @@ -816,6 +822,13 @@ public CreateContainerCmd withMemorySwap(Long memorySwap) {
return this;
}

@Override
public CreateContainerCmd withMemorySwappiness(Integer memorySwappiness) {
checkNotNull(memorySwappiness, "memorySwappiness was not specified");
hostConfig.withMemorySwappiness(memorySwappiness);
return this;
}

@Override
public CreateContainerCmd withName(String name) {
checkNotNull(name, "name was not specified");
Expand Down
20 changes: 20 additions & 0 deletions src/test/java/com/github/dockerjava/cmd/CreateContainerCmdIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assume.assumeThat;

@NotThreadSafe
Expand Down Expand Up @@ -294,6 +295,25 @@ public void createContainerWithLink() throws DockerException {
"container1Link")}));
}

@Test
public void createContainerWithMemorySwappiness() throws DockerException {
CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
.withCmd("sleep", "9999")
.withMemorySwappiness(42)
.exec();
assertThat(container.getId(), not(isEmptyString()));
LOG.info("Created container {}", container.toString());

dockerRule.getClient().startContainerCmd(container.getId()).exec();
LOG.info("Started container {}", container.toString());

InspectContainerResponse inspectContainerResponse = dockerRule.getClient()
.inspectContainerCmd(container.getId())
.exec();
LOG.info("Container Inspect: {}", inspectContainerResponse.toString());
assertSame(42, inspectContainerResponse.getHostConfig().getMemorySwappiness());
}

@Test
public void createContainerWithLinkInCustomNetwork() throws DockerException {
String containerName1 = "containerCustomlink_" + dockerRule.getKind();
Expand Down