Skip to content

Commit 4f8f7b9

Browse files
authored
Add platform to CreateContainerCmd (#1638)
1 parent 0ae5930 commit 4f8f7b9

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

docker-java-api/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,11 @@ default CreateContainerCmd withUlimits(List<Ulimit> ulimits) {
10061006
return this;
10071007
}
10081008

1009+
@CheckForNull
1010+
String getPlatform();
1011+
1012+
CreateContainerCmd withPlatform(String platform);
1013+
10091014
/**
10101015
* @throws NotFoundException No such container
10111016
* @throws ConflictException Named container already exists

docker-java-core/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ public class CreateContainerCmdImpl extends AbstrDockerCmd<CreateContainerCmd, C
133133

134134
private AuthConfig authConfig;
135135

136+
private String platform;
137+
136138
public CreateContainerCmdImpl(CreateContainerCmd.Exec exec, AuthConfig authConfig, String image) {
137139
super(exec);
138140
withAuthConfig(authConfig);
@@ -553,6 +555,18 @@ public CreateContainerCmdImpl withOnBuild(List<String> onBuild) {
553555
return this;
554556
}
555557

558+
@CheckForNull
559+
@Override
560+
public String getPlatform() {
561+
return platform;
562+
}
563+
564+
@Override
565+
public CreateContainerCmd withPlatform(String platform) {
566+
this.platform = platform;
567+
return this;
568+
}
569+
556570
/**
557571
* @throws NotFoundException No such container
558572
* @throws ConflictException Named container already exists

docker-java-core/src/main/java/com/github/dockerjava/core/exec/CreateContainerCmdExec.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ protected CreateContainerResponse execute(CreateContainerCmd command) {
2727
webResource = webResource.queryParam("name", command.getName());
2828
}
2929

30+
if (command.getPlatform() != null) {
31+
webResource = webResource.queryParam("platform", command.getPlatform());
32+
}
33+
3034
LOGGER.trace("POST: {} ", webResource);
3135
return resourceWithOptionalAuthConfig(command.getAuthConfig(), webResource.request())
3236
.accept(MediaType.APPLICATION_JSON)

0 commit comments

Comments
 (0)