consoleSize) {
+ this.consoleSize = consoleSize;
+ return this;
+ }
+
+ @CheckForNull
+ public Isolation getIsolation() {
+ return isolation;
+ }
+
+ public HostConfig withIsolation(Isolation isolation) {
+ this.isolation = isolation;
+ return this;
+ }
+
+ @CheckForNull
+ public Long getCpuRealtimePeriod() {
+ return cpuRealtimePeriod;
+ }
+
+ public HostConfig withCpuRealtimePeriod(Long cpuRealtimePeriod) {
+ this.cpuRealtimePeriod = cpuRealtimePeriod;
+ return this;
+ }
+
+ @CheckForNull
+ public Long getCpuRealtimeRuntime() {
+ return cpuRealtimeRuntime;
+ }
+
+ public HostConfig withCpuRealtimeRuntime(Long cpuRealtimeRuntime) {
+ this.cpuRealtimeRuntime = cpuRealtimeRuntime;
+ return this;
+ }
@Override
public String toString() {
diff --git a/src/main/java/com/github/dockerjava/api/model/Info.java b/src/main/java/com/github/dockerjava/api/model/Info.java
index 6925df5f2..fdbaa4722 100644
--- a/src/main/java/com/github/dockerjava/api/model/Info.java
+++ b/src/main/java/com/github/dockerjava/api/model/Info.java
@@ -230,6 +230,12 @@ public class Info implements Serializable {
@JsonProperty("Swarm")
private SwarmInfo swarm;
+ /**
+ * @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_25}
+ */
+ @JsonProperty("Isolation")
+ private String isolation;
+
/**
* @see #architecture
*/
@@ -1046,6 +1052,22 @@ public Info withSwarm(SwarmInfo swarm) {
return this;
}
+ /**
+ * @see #isolation
+ */
+ @CheckForNull
+ public String getIsolation() {
+ return isolation;
+ }
+
+ /**
+ * @see #isolation
+ */
+ public Info withIsolation(String isolation) {
+ this.isolation = isolation;
+ return this;
+ }
+
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
diff --git a/src/main/java/com/github/dockerjava/api/model/Isolation.java b/src/main/java/com/github/dockerjava/api/model/Isolation.java
new file mode 100644
index 000000000..c59c8848f
--- /dev/null
+++ b/src/main/java/com/github/dockerjava/api/model/Isolation.java
@@ -0,0 +1,41 @@
+package com.github.dockerjava.api.model;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+import java.io.Serializable;
+
+public enum Isolation implements Serializable {
+ DEFAULT("default"),
+
+ PROCESS("process"),
+
+ HYPERV("hyperv");
+
+ private String value;
+
+ Isolation(String value) {
+ this.value = value;
+ }
+
+ @JsonValue
+ public String getValue() {
+ return value;
+ }
+
+ @JsonCreator
+ public static Isolation fromValue(String text) {
+ for (Isolation b : Isolation.values()) {
+ if (String.valueOf(b.value).equals(text)) {
+ return b;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(value);
+ }
+
+}
diff --git a/src/main/java/com/github/dockerjava/api/model/LogConfig.java b/src/main/java/com/github/dockerjava/api/model/LogConfig.java
index 2a3301287..4ea19041e 100644
--- a/src/main/java/com/github/dockerjava/api/model/LogConfig.java
+++ b/src/main/java/com/github/dockerjava/api/model/LogConfig.java
@@ -1,28 +1,19 @@
package com.github.dockerjava.api.model;
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.Map;
-
+import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.ObjectCodec;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+import javax.annotation.CheckForNull;
+import java.io.Serializable;
+import java.util.Map;
/**
* Log driver to use for a created/running container. The available types are:
- *
+ *
* json-file (default) syslog journald none
- *
+ *
* If a driver is specified that is NOT supported,docker will default to null. If configs are supplied that are not supported by the type
* docker will ignore them. In most cases setting the config option to null will suffice. Consult the docker remote API for a more detailed
* and up-to-date explanation of the available types and their options.
@@ -68,19 +59,19 @@ public LogConfig setConfig(Map config) {
return this;
}
- @JsonDeserialize(using = LoggingType.Deserializer.class)
- @JsonSerialize(using = LoggingType.Serializer.class)
public enum LoggingType {
+ NONE("none"),
DEFAULT("json-file"),
+ ETWLOGS("etwlogs"),
JSON_FILE("json-file"),
- NONE("none"),
SYSLOG("syslog"),
JOURNALD("journald"),
GELF("gelf"),
FLUENTD("fluentd"),
AWSLOGS("awslogs"),
DB("db"), // Synology specific driver
- SPLUNK("splunk");
+ SPLUNK("splunk"),
+ GCPLOGS("gcplogs");
private String type;
@@ -88,34 +79,25 @@ public enum LoggingType {
this.type = type;
}
+ @JsonValue
public String getType() {
return type;
}
- public static final class Serializer extends JsonSerializer {
- @Override
- public void serialize(LoggingType value, JsonGenerator jgen, SerializerProvider provider)
- throws IOException, JsonProcessingException {
- jgen.writeString(value.getType());
+ @JsonCreator
+ @CheckForNull
+ public static LoggingType fromValue(String text) {
+ for (LoggingType b : LoggingType.values()) {
+ if (String.valueOf(b.type).equals(text)) {
+ return b;
+ }
}
+ return null;
}
- public static final class Deserializer extends JsonDeserializer {
- @Override
- public LoggingType deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
- throws IOException, JsonProcessingException {
-
- ObjectCodec oc = jsonParser.getCodec();
- JsonNode node = oc.readTree(jsonParser);
-
- for (LoggingType loggingType : values()) {
- if (loggingType.getType().equals(node.asText())) {
- return loggingType;
- }
- }
-
- throw new IllegalArgumentException("No enum constant " + LoggingType.class + "." + node.asText());
- }
+ @Override
+ public String toString() {
+ return String.valueOf(type);
}
}
}
diff --git a/src/main/java/com/github/dockerjava/api/model/MemoryStatsConfig.java b/src/main/java/com/github/dockerjava/api/model/MemoryStatsConfig.java
index 77c9f0b28..4320a89ed 100644
--- a/src/main/java/com/github/dockerjava/api/model/MemoryStatsConfig.java
+++ b/src/main/java/com/github/dockerjava/api/model/MemoryStatsConfig.java
@@ -15,18 +15,29 @@
public class MemoryStatsConfig implements Serializable {
private static final long serialVersionUID = 1L;
+ @JsonProperty("stats")
+ private StatsConfig stats;
+
@JsonProperty("usage")
private Long usage;
@JsonProperty("max_usage")
private Long maxUsage;
- @JsonProperty("stats")
- private StatsConfig stats;
+ @JsonProperty("failcnt")
+ private Long failcnt;
@JsonProperty("limit")
private Long limit;
+ /**
+ * @see #stats
+ */
+ @CheckForNull
+ public StatsConfig getStats() {
+ return stats;
+ }
+
/**
* @see #usage
*/
@@ -44,11 +55,10 @@ public Long getMaxUsage() {
}
/**
- * @see #stats
+ * @see #failcnt
*/
- @CheckForNull
- public StatsConfig getStats() {
- return stats;
+ public Long getFailcnt() {
+ return failcnt;
}
/**
diff --git a/src/main/java/com/github/dockerjava/api/model/PruneResponse.java b/src/main/java/com/github/dockerjava/api/model/PruneResponse.java
new file mode 100644
index 000000000..d6653cdc6
--- /dev/null
+++ b/src/main/java/com/github/dockerjava/api/model/PruneResponse.java
@@ -0,0 +1,65 @@
+package com.github.dockerjava.api.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
+import java.io.Serializable;
+
+/**
+ * Delete unused content (containers, images, volumes, networks, build relicts)
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class PruneResponse implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @JsonProperty("SpaceReclaimed")
+ private Long spaceReclaimed;
+
+ /**
+ * Default constructor for the deserialization.
+ */
+ public PruneResponse() {
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param spaceReclaimed Space reclaimed after purification
+ */
+ public PruneResponse(Long spaceReclaimed) {
+ this.spaceReclaimed = spaceReclaimed;
+ }
+
+ /**
+ * Disk space reclaimed in bytes
+ */
+ public Long getSpaceReclaimed() {
+ return spaceReclaimed;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("PruneResponse {");
+ sb.append(" spaceReclaimed: ").append(getSpaceReclaimed());
+ sb.append("}");
+ return sb.toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof Ulimit) {
+ Ulimit other = (Ulimit) o;
+ return new EqualsBuilder().append(spaceReclaimed, other.getName()).isEquals();
+ } else {
+ return super.equals(o);
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(spaceReclaimed).toHashCode();
+ }
+}
diff --git a/src/main/java/com/github/dockerjava/api/model/PruneType.java b/src/main/java/com/github/dockerjava/api/model/PruneType.java
new file mode 100644
index 000000000..10d8704fd
--- /dev/null
+++ b/src/main/java/com/github/dockerjava/api/model/PruneType.java
@@ -0,0 +1,9 @@
+package com.github.dockerjava.api.model;
+
+public enum PruneType {
+ BUILD,
+ CONTAINERS,
+ IMAGES,
+ NETWORKS,
+ VOLUMES
+}
diff --git a/src/main/java/com/github/dockerjava/api/model/ServiceModeConfig.java b/src/main/java/com/github/dockerjava/api/model/ServiceModeConfig.java
index d2ffe3d95..9aeec2e1c 100644
--- a/src/main/java/com/github/dockerjava/api/model/ServiceModeConfig.java
+++ b/src/main/java/com/github/dockerjava/api/model/ServiceModeConfig.java
@@ -14,7 +14,7 @@
* @since {@link RemoteApiVersion#VERSION_1_24}
*/
public class ServiceModeConfig implements Serializable {
- public static final Long serialVersionUID = 1L;
+ public static final long serialVersionUID = 1L;
/**
* @since 1.24
diff --git a/src/main/java/com/github/dockerjava/api/model/StatsConfig.java b/src/main/java/com/github/dockerjava/api/model/StatsConfig.java
index a732c78fa..19b95a7ff 100644
--- a/src/main/java/com/github/dockerjava/api/model/StatsConfig.java
+++ b/src/main/java/com/github/dockerjava/api/model/StatsConfig.java
@@ -5,7 +5,7 @@
import javax.annotation.CheckForNull;
import java.io.Serializable;
-class StatsConfig implements Serializable {
+public class StatsConfig implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("active_anon")
diff --git a/src/main/java/com/github/dockerjava/api/model/Ulimit.java b/src/main/java/com/github/dockerjava/api/model/Ulimit.java
index abcf298bd..5a37810a4 100644
--- a/src/main/java/com/github/dockerjava/api/model/Ulimit.java
+++ b/src/main/java/com/github/dockerjava/api/model/Ulimit.java
@@ -25,12 +25,10 @@ public class Ulimit implements Serializable {
private Integer hard;
public Ulimit() {
-
}
public Ulimit(String name, int soft, int hard) {
checkNotNull(name, "Name is null");
-
this.name = name;
this.soft = soft;
this.hard = hard;
diff --git a/src/main/java/com/github/dockerjava/api/model/Version.java b/src/main/java/com/github/dockerjava/api/model/Version.java
index f08c411e2..2dcfdcb86 100644
--- a/src/main/java/com/github/dockerjava/api/model/Version.java
+++ b/src/main/java/com/github/dockerjava/api/model/Version.java
@@ -9,6 +9,7 @@
import javax.annotation.CheckForNull;
import java.io.Serializable;
+import java.util.List;
/**
* Used for `/version`
@@ -53,6 +54,24 @@ public class Version implements Serializable {
@JsonProperty("Experimental")
private Boolean experimental;
+ /**
+ * @since ~{@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_25}
+ */
+ @JsonProperty("MinAPIVersion")
+ private String minAPIVersion;
+
+ /**
+ * @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_35}
+ */
+ @JsonProperty("Platform")
+ private VersionPlatform platform;
+
+ /**
+ * @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_35}
+ */
+ @JsonProperty("Components")
+ private List components;
+
public String getVersion() {
return version;
}
@@ -97,6 +116,30 @@ public Boolean getExperimental() {
return experimental;
}
+ /**
+ * @see #minAPIVersion
+ */
+ @CheckForNull
+ public String getMinAPIVersion() {
+ return minAPIVersion;
+ }
+
+ /**
+ * @see #platform
+ */
+ @CheckForNull
+ public VersionPlatform getPlatform() {
+ return platform;
+ }
+
+ /**
+ * @see #components
+ */
+ @CheckForNull
+ public List getComponents() {
+ return components;
+ }
+
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
diff --git a/src/main/java/com/github/dockerjava/api/model/VersionComponent.java b/src/main/java/com/github/dockerjava/api/model/VersionComponent.java
new file mode 100644
index 000000000..11fff0abc
--- /dev/null
+++ b/src/main/java/com/github/dockerjava/api/model/VersionComponent.java
@@ -0,0 +1,95 @@
+package com.github.dockerjava.api.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.github.dockerjava.core.RemoteApiVersion;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+import javax.annotation.CheckForNull;
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * Part of {@link Version}
+ *
+ * @since {@link RemoteApiVersion#VERSION_1_35}
+ * @author Dmitry Tretyakov
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class VersionComponent implements Serializable {
+ public static final Long serialVersionUID = 1L;
+
+ @JsonProperty("Details")
+ private Map details;
+
+ @JsonProperty("Name")
+ private String name;
+
+ @JsonProperty("Version")
+ private String version;
+
+ /**
+ * @see #details
+ */
+ @CheckForNull
+ public Map getDetails() {
+ return details;
+ }
+
+ /**
+ * @see #details
+ */
+ public VersionComponent withDetails(Map details) {
+ this.details = details;
+ return this;
+ }
+
+ /**
+ * @see #name
+ */
+ @CheckForNull
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see #name
+ */
+ public VersionComponent withName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * @see #version
+ */
+ @CheckForNull
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * @see #version
+ */
+ public VersionComponent withVersion(String version) {
+ this.version = version;
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return EqualsBuilder.reflectionEquals(this, o);
+ }
+
+ @Override
+ public int hashCode() {
+ return HashCodeBuilder.reflectionHashCode(this);
+ }
+}
diff --git a/src/main/java/com/github/dockerjava/api/model/VersionPlatform.java b/src/main/java/com/github/dockerjava/api/model/VersionPlatform.java
new file mode 100644
index 000000000..b3160438f
--- /dev/null
+++ b/src/main/java/com/github/dockerjava/api/model/VersionPlatform.java
@@ -0,0 +1,56 @@
+package com.github.dockerjava.api.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.github.dockerjava.core.RemoteApiVersion;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+import javax.annotation.CheckForNull;
+import java.io.Serializable;
+
+/**
+ * Part of {@link Version}
+ *
+ * @since {@link RemoteApiVersion#VERSION_1_35}
+ * @author Dmitry Tretyakov
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class VersionPlatform implements Serializable {
+ public static final Long serialVersionUID = 1L;
+
+ @JsonProperty("Name")
+ private String name;
+
+ /**
+ * @see #name
+ */
+ @CheckForNull
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see #name
+ */
+ public VersionPlatform withName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return EqualsBuilder.reflectionEquals(this, o);
+ }
+
+ @Override
+ public int hashCode() {
+ return HashCodeBuilder.reflectionHashCode(this);
+ }
+}
diff --git a/src/main/java/com/github/dockerjava/core/AbstractDockerCmdExecFactory.java b/src/main/java/com/github/dockerjava/core/AbstractDockerCmdExecFactory.java
index 91347de2b..c822b4cc2 100644
--- a/src/main/java/com/github/dockerjava/core/AbstractDockerCmdExecFactory.java
+++ b/src/main/java/com/github/dockerjava/core/AbstractDockerCmdExecFactory.java
@@ -44,6 +44,7 @@
import com.github.dockerjava.api.command.LogSwarmObjectCmd;
import com.github.dockerjava.api.command.PauseContainerCmd;
import com.github.dockerjava.api.command.PingCmd;
+import com.github.dockerjava.api.command.PruneCmd;
import com.github.dockerjava.api.command.PullImageCmd;
import com.github.dockerjava.api.command.PushImageCmd;
import com.github.dockerjava.api.command.RemoveContainerCmd;
@@ -110,6 +111,7 @@
import com.github.dockerjava.core.exec.LogContainerCmdExec;
import com.github.dockerjava.core.exec.PauseContainerCmdExec;
import com.github.dockerjava.core.exec.PingCmdExec;
+import com.github.dockerjava.core.exec.PruneCmdExec;
import com.github.dockerjava.core.exec.PullImageCmdExec;
import com.github.dockerjava.core.exec.PushImageCmdExec;
import com.github.dockerjava.core.exec.RemoveContainerCmdExec;
@@ -492,5 +494,10 @@ public LogSwarmObjectCmd.Exec logSwarmObjectExec(String endpoint) {
return new LogSwarmObjectExec(getBaseResource(), getDockerClientConfig(), endpoint);
}
+ @Override
+ public PruneCmd.Exec pruneCmdExec() {
+ return new PruneCmdExec(getBaseResource(), getDockerClientConfig());
+ }
+
protected abstract WebTarget getBaseResource();
}
diff --git a/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java b/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java
index 8517d89a9..c77cbb5b7 100644
--- a/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java
+++ b/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java
@@ -11,6 +11,8 @@
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -231,14 +233,16 @@ public String getRegistryUrl() {
return registryUrl;
}
+ @CheckForNull
public String getDockerConfigPath() {
return dockerConfigPath;
}
+ @Nonnull
public DockerConfigFile getDockerConfig() {
if (dockerConfig == null) {
try {
- dockerConfig = DockerConfigFile.loadConfig(new File(getDockerConfigPath()));
+ dockerConfig = DockerConfigFile.loadConfig(getDockerConfigPath());
} catch (IOException e) {
throw new DockerClientException("Failed to parse docker configuration file", e);
}
diff --git a/src/main/java/com/github/dockerjava/core/DockerClientImpl.java b/src/main/java/com/github/dockerjava/core/DockerClientImpl.java
index edc634cb9..edf3bfc29 100644
--- a/src/main/java/com/github/dockerjava/core/DockerClientImpl.java
+++ b/src/main/java/com/github/dockerjava/core/DockerClientImpl.java
@@ -44,6 +44,7 @@
import com.github.dockerjava.api.command.LogSwarmObjectCmd;
import com.github.dockerjava.api.command.PauseContainerCmd;
import com.github.dockerjava.api.command.PingCmd;
+import com.github.dockerjava.api.command.PruneCmd;
import com.github.dockerjava.api.command.PullImageCmd;
import com.github.dockerjava.api.command.PushImageCmd;
import com.github.dockerjava.api.command.RemoveContainerCmd;
@@ -69,6 +70,7 @@
import com.github.dockerjava.api.command.WaitContainerCmd;
import com.github.dockerjava.api.model.AuthConfig;
import com.github.dockerjava.api.model.Identifier;
+import com.github.dockerjava.api.model.PruneType;
import com.github.dockerjava.api.model.ServiceSpec;
import com.github.dockerjava.api.model.SwarmSpec;
import com.github.dockerjava.core.command.AttachContainerCmdImpl;
@@ -113,6 +115,7 @@
import com.github.dockerjava.core.command.LogSwarmObjectImpl;
import com.github.dockerjava.core.command.PauseContainerCmdImpl;
import com.github.dockerjava.core.command.PingCmdImpl;
+import com.github.dockerjava.core.command.PruneCmdImpl;
import com.github.dockerjava.core.command.PullImageCmdImpl;
import com.github.dockerjava.core.command.PushImageCmdImpl;
import com.github.dockerjava.core.command.RemoveContainerCmdImpl;
@@ -579,6 +582,11 @@ public LogSwarmObjectCmd logTaskCmd(String taskId) {
return new LogSwarmObjectImpl(getDockerCmdExecFactory().logSwarmObjectExec("tasks"), taskId);
}
+ @Override
+ public PruneCmd pruneCmd(PruneType pruneType) {
+ return new PruneCmdImpl(getDockerCmdExecFactory().pruneCmdExec(), pruneType);
+ }
+
@Override
public ListTasksCmd listTasksCmd() {
return new ListTasksCmdImpl(getDockerCmdExecFactory().listTasksCmdExec());
diff --git a/src/main/java/com/github/dockerjava/core/DockerConfigFile.java b/src/main/java/com/github/dockerjava/core/DockerConfigFile.java
index 01cacb5c8..ac1e3cf28 100644
--- a/src/main/java/com/github/dockerjava/core/DockerConfigFile.java
+++ b/src/main/java/com/github/dockerjava/core/DockerConfigFile.java
@@ -10,6 +10,8 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -27,7 +29,7 @@ public class DockerConfigFile {
private static final TypeReference> CONFIG_MAP_TYPE = new TypeReference>() {
};
- @JsonProperty()
+ @JsonProperty
private final Map auths;
public DockerConfigFile() {
@@ -38,6 +40,7 @@ private DockerConfigFile(Map authConfigMap) {
auths = authConfigMap;
}
+ @Nonnull
public Map getAuths() {
return auths;
}
@@ -46,7 +49,8 @@ void addAuthConfig(AuthConfig config) {
auths.put(config.getRegistryAddress(), config);
}
- public AuthConfig resolveAuthConfig(String hostname) {
+ @CheckForNull
+ public AuthConfig resolveAuthConfig(@CheckForNull String hostname) {
if (StringUtils.isEmpty(hostname) || AuthConfig.DEFAULT_SERVER_ADDRESS.equals(hostname)) {
return auths.get(AuthConfig.DEFAULT_SERVER_ADDRESS);
}
@@ -70,6 +74,7 @@ public AuthConfig resolveAuthConfig(String hostname) {
return null;
}
+ @Nonnull
public AuthConfigurations getAuthConfigurations() {
final AuthConfigurations authConfigurations = new AuthConfigurations();
for (Map.Entry authConfigEntry : auths.entrySet()) {
@@ -112,7 +117,13 @@ public String toString() {
return "DockerConfigFile [auths=" + auths + "]";
}
- public static DockerConfigFile loadConfig(File dockerConfigPath) throws IOException {
+ @Nonnull
+ public static DockerConfigFile loadConfig(@CheckForNull String dockerConfigPath) throws IOException {
+ // no any configs, but for empty auths return non null object
+ if (dockerConfigPath == null) {
+ return new DockerConfigFile();
+ }
+
//parse new docker config file format
DockerConfigFile dockerConfig = loadCurrentConfig(dockerConfigPath);
@@ -136,8 +147,9 @@ public static DockerConfigFile loadConfig(File dockerConfigPath) throws IOExcept
return dockerConfig;
}
- private static DockerConfigFile loadCurrentConfig(File dockerConfigPath) throws IOException {
- File dockerCfgFile = new File(dockerConfigPath, File.separator + DOCKER_CFG);
+ @CheckForNull
+ private static DockerConfigFile loadCurrentConfig(@CheckForNull String dockerConfigPath) throws IOException {
+ File dockerCfgFile = new File(dockerConfigPath, DOCKER_CFG);
if (!dockerCfgFile.exists() || !dockerCfgFile.isFile()) {
return null;
@@ -150,8 +162,9 @@ private static DockerConfigFile loadCurrentConfig(File dockerConfigPath) throws
}
}
- private static DockerConfigFile loadLegacyConfig(File dockerConfigPath) throws IOException {
- File dockerLegacyCfgFile = new File(dockerConfigPath, File.separator + DOCKER_LEGACY_CFG);
+ @CheckForNull
+ private static DockerConfigFile loadLegacyConfig(String dockerConfigPath) throws IOException {
+ File dockerLegacyCfgFile = new File(dockerConfigPath, DOCKER_LEGACY_CFG);
if (!dockerLegacyCfgFile.exists() || !dockerLegacyCfgFile.isFile()) {
return null;
diff --git a/src/main/java/com/github/dockerjava/core/RemoteApiVersion.java b/src/main/java/com/github/dockerjava/core/RemoteApiVersion.java
index dcf47d9e6..66b5b47f7 100644
--- a/src/main/java/com/github/dockerjava/core/RemoteApiVersion.java
+++ b/src/main/java/com/github/dockerjava/core/RemoteApiVersion.java
@@ -87,6 +87,8 @@ public class RemoteApiVersion implements Serializable {
public static final RemoteApiVersion VERSION_1_34 = RemoteApiVersion.create(1, 34);
public static final RemoteApiVersion VERSION_1_35 = RemoteApiVersion.create(1, 35);
public static final RemoteApiVersion VERSION_1_36 = RemoteApiVersion.create(1, 36);
+ public static final RemoteApiVersion VERSION_1_37 = RemoteApiVersion.create(1, 37);
+ public static final RemoteApiVersion VERSION_1_38 = RemoteApiVersion.create(1, 38);
/**
diff --git a/src/main/java/com/github/dockerjava/core/async/ResultCallbackTemplate.java b/src/main/java/com/github/dockerjava/core/async/ResultCallbackTemplate.java
index f624eccd3..727c91164 100644
--- a/src/main/java/com/github/dockerjava/core/async/ResultCallbackTemplate.java
+++ b/src/main/java/com/github/dockerjava/core/async/ResultCallbackTemplate.java
@@ -74,10 +74,13 @@ public void onComplete() {
public void close() throws IOException {
if (!closed) {
closed = true;
- if (stream != null) {
- stream.close();
+ try {
+ if (stream != null) {
+ stream.close();
+ }
+ } finally {
+ completed.countDown();
}
- completed.countDown();
}
}
diff --git a/src/main/java/com/github/dockerjava/core/command/BuildImageCmdImpl.java b/src/main/java/com/github/dockerjava/core/command/BuildImageCmdImpl.java
index d5dc26af3..0384ba145 100644
--- a/src/main/java/com/github/dockerjava/core/command/BuildImageCmdImpl.java
+++ b/src/main/java/com/github/dockerjava/core/command/BuildImageCmdImpl.java
@@ -68,6 +68,10 @@ public class BuildImageCmdImpl extends AbstrAsyncDockerCmd onBuild;
+
@JsonProperty("NetworkDisabled")
private Boolean networkDisabled;
@@ -110,12 +110,18 @@ public class CreateContainerCmdImpl extends AbstrDockerCmd labels;
+ @JsonProperty("Shell")
+ private List shell;
+
@JsonProperty("NetworkingConfig")
private NetworkingConfig networkingConfig;
@@ -145,520 +151,66 @@ public CreateContainerCmd withAuthConfig(AuthConfig authConfig) {
return this;
}
- /**
- * @throws NotFoundException
- * No such container
- * @throws ConflictException
- * Named container already exists
- */
- @Override
- public CreateContainerResponse exec() throws NotFoundException, ConflictException {
- //code flow taken from https://github.com/docker/docker/blob/master/runconfig/opts/parse.go
- ContainerNetwork containerNetwork = null;
-
- if (ipv4Address != null || ipv6Address != null) {
- containerNetwork = new ContainerNetwork()
- .withIpamConfig(new ContainerNetwork.Ipam()
- .withIpv4Address(ipv4Address)
- .withIpv6Address(ipv6Address)
- );
-
- }
-
- if (hostConfig.isUserDefinedNetwork() && hostConfig.getLinks().length > 0) {
- if (containerNetwork == null) {
- containerNetwork = new ContainerNetwork();
- }
-
- containerNetwork.withLinks(hostConfig.getLinks());
- }
-
- if (aliases != null) {
- if (containerNetwork == null) {
- containerNetwork = new ContainerNetwork();
- }
-
- containerNetwork.withAliases(aliases);
- }
-
- if (containerNetwork != null) {
- networkingConfig = new NetworkingConfig()
- .withEndpointsConfig(singletonMap(hostConfig.getNetworkMode(), containerNetwork));
- }
-
- return super.exec();
- }
-
- @Override
- @JsonIgnore
- public List getAliases() {
- return aliases;
- }
-
- @Override
- @JsonIgnore
- public Bind[] getBinds() {
- return hostConfig.getBinds();
- }
-
- @Override
- @JsonIgnore
- public Integer getBlkioWeight() {
- return hostConfig.getBlkioWeight();
- }
-
- @Override
- @JsonIgnore
- public Capability[] getCapAdd() {
- return hostConfig.getCapAdd();
- }
-
- @Override
- @JsonIgnore
- public Capability[] getCapDrop() {
- return hostConfig.getCapDrop();
- }
-
- @Override
- public String[] getCmd() {
- return cmd;
- }
-
- @Override
- @JsonIgnore
- public Integer getCpuPeriod() {
- return hostConfig.getCpuPeriod();
- }
-
- @Override
- @JsonIgnore
- public String getCpusetCpus() {
- return hostConfig.getCpusetCpus();
- }
-
- @Override
- @JsonIgnore
- public String getCpusetMems() {
- return hostConfig.getCpusetMems();
- }
-
- @Override
- @JsonIgnore
- public Integer getCpuShares() {
- return hostConfig.getCpuShares();
- }
-
- @Override
- @JsonIgnore
- public Device[] getDevices() {
- return hostConfig.getDevices();
- }
-
- @Override
- @JsonIgnore
- public String[] getDns() {
- return hostConfig.getDns();
- }
-
- @Override
- @JsonIgnore
- public String[] getDnsSearch() {
- return hostConfig.getDnsSearch();
- }
-
- @Override
- public String getDomainName() {
- return domainName;
- }
-
- @Override
- public String[] getEntrypoint() {
- return entrypoint;
- }
-
- @Override
- public String[] getEnv() {
- return env;
- }
-
- @Override
- @JsonIgnore
- public ExposedPort[] getExposedPorts() {
- return exposedPorts.getExposedPorts();
- }
-
- /**
- * @see #stopSignal
- */
- @JsonIgnore
- @Override
- public String getStopSignal() {
- return stopSignal;
- }
-
- @Override
- @JsonIgnore
- public String[] getExtraHosts() {
- return hostConfig.getExtraHosts();
- }
-
- @Override
- public String getHostName() {
- return hostName;
- }
-
- @Override
- public String getImage() {
- return image;
- }
-
- @Override
- public String getIpv4Address() {
- return ipv4Address;
- }
-
- @Override
- public String getIpv6Address() {
- return ipv6Address;
- }
-
- @Override
- @JsonIgnore
- public Map getLabels() {
- return labels;
- }
-
- @Override
- @JsonIgnore
- public Link[] getLinks() {
- return hostConfig.getLinks();
- }
-
- @Override
- @JsonIgnore
- public LxcConf[] getLxcConf() {
- return hostConfig.getLxcConf();
- }
-
- @Override
- @JsonIgnore
- public LogConfig getLogConfig() {
- return hostConfig.getLogConfig();
- }
-
- @Override
- public String getMacAddress() {
- return macAddress;
- }
-
- @Override
- @JsonIgnore
- public Long getMemory() {
- return hostConfig.getMemory();
- }
-
- @Override
- @JsonIgnore
- public Long getMemorySwap() {
- return hostConfig.getMemorySwap();
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- @JsonIgnore
- public String getNetworkMode() {
- return hostConfig.getNetworkMode();
- }
-
- @Override
- @JsonIgnore
- public Ports getPortBindings() {
- return hostConfig.getPortBindings();
- }
-
- @Override
- public String[] getPortSpecs() {
- return portSpecs;
- }
-
- @Override
- @JsonIgnore
- public RestartPolicy getRestartPolicy() {
- return hostConfig.getRestartPolicy();
- }
-
- @Override
- @JsonIgnore
- public Ulimit[] getUlimits() {
- return hostConfig.getUlimits();
- }
-
- @Override
- public String getUser() {
- return user;
- }
-
- @Override
- @JsonIgnore
- public Volume[] getVolumes() {
- return volumes.getVolumes();
- }
-
- @Override
- @JsonIgnore
- public VolumesFrom[] getVolumesFrom() {
- return hostConfig.getVolumesFrom();
- }
-
- @Override
- public String getWorkingDir() {
- return workingDir;
- }
-
- @Override
- public Boolean isAttachStderr() {
- return attachStderr;
- }
-
- @Override
- public Boolean isAttachStdin() {
- return attachStdin;
- }
-
- @Override
- public Boolean isAttachStdout() {
- return attachStdout;
- }
-
- @Override
- public Boolean isNetworkDisabled() {
- return networkDisabled;
- }
-
- @Override
- @JsonIgnore
- public Boolean getOomKillDisable() {
- return hostConfig.getOomKillDisable();
- }
-
- @Override
- @JsonIgnore
- public Boolean getPrivileged() {
- return hostConfig.getPrivileged();
- }
-
- @Override
- @JsonIgnore
- public Boolean getPublishAllPorts() {
- return hostConfig.getPublishAllPorts();
- }
-
- @Override
- @JsonIgnore
- public Boolean getReadonlyRootfs() {
- return hostConfig.getReadonlyRootfs();
- }
-
- @Override
- public Boolean isStdInOnce() {
- return stdInOnce;
- }
-
- @Override
- public Boolean isStdinOpen() {
- return stdinOpen;
- }
-
- @Override
- public Boolean isTty() {
- return tty;
- }
-
- @Override
- @JsonIgnore
- public String getPidMode() {
- return hostConfig.getPidMode();
- }
-
- @Override
- public HostConfig getHostConfig() {
- return hostConfig;
- }
-
- @Override
- public String getCgroupParent() {
- return hostConfig.getCgroupParent();
- }
-
- @Override
- public CreateContainerCmd withAliases(String... aliases) {
- this.aliases = Arrays.asList(aliases);
- return this;
- }
-
- @Override
- public CreateContainerCmd withAliases(List aliases) {
- checkNotNull(aliases, "aliases was not specified");
- this.aliases = aliases;
- return this;
- }
-
- @Override
- public CreateContainerCmd withAttachStderr(Boolean attachStderr) {
- checkNotNull(attachStderr, "attachStderr was not specified");
- this.attachStderr = attachStderr;
- return this;
- }
-
- @Override
- public CreateContainerCmd withAttachStdin(Boolean attachStdin) {
- checkNotNull(attachStdin, "attachStdin was not specified");
- this.attachStdin = attachStdin;
- return this;
- }
-
- @Override
- public CreateContainerCmd withAttachStdout(Boolean attachStdout) {
- checkNotNull(attachStdout, "attachStdout was not specified");
- this.attachStdout = attachStdout;
- return this;
- }
-
- @Override
- public CreateContainerCmd withBinds(Bind... binds) {
- checkNotNull(binds, "binds was not specified");
- hostConfig.setBinds(binds);
- return this;
- }
-
- @Override
- public CreateContainerCmd withBinds(List binds) {
- checkNotNull(binds, "binds was not specified");
- return withBinds(binds.toArray(new Bind[binds.size()]));
- }
-
- @Override
- public CreateContainerCmd withBlkioWeight(Integer blkioWeight) {
- checkNotNull(blkioWeight, "blkioWeight was not specified");
- hostConfig.withBlkioWeight(blkioWeight);
- return this;
- }
-
- @Override
- public CreateContainerCmd withCapAdd(Capability... capAdd) {
- checkNotNull(capAdd, "capAdd was not specified");
- hostConfig.withCapAdd(capAdd);
- return this;
- }
-
- @Override
- public CreateContainerCmd withCapAdd(List capAdd) {
- checkNotNull(capAdd, "capAdd was not specified");
- return withCapAdd(capAdd.toArray(new Capability[capAdd.size()]));
- }
-
- @Override
- public CreateContainerCmd withCapDrop(Capability... capDrop) {
- checkNotNull(capDrop, "capDrop was not specified");
- hostConfig.withCapDrop(capDrop);
- return this;
- }
-
- @Override
- public CreateContainerCmd withCapDrop(List capDrop) {
- checkNotNull(capDrop, "capDrop was not specified");
- return withCapDrop(capDrop.toArray(new Capability[capDrop.size()]));
- }
-
- @Override
- public CreateContainerCmd withCmd(String... cmd) {
- checkNotNull(cmd, "cmd was not specified");
- this.cmd = cmd;
- return this;
- }
-
@Override
- public CreateContainerCmd withCmd(List cmd) {
- checkNotNull(cmd, "cmd was not specified");
- return withCmd(cmd.toArray(new String[cmd.size()]));
+ @JsonIgnore
+ public List getAliases() {
+ return aliases;
}
@Override
- public CreateContainerCmd withContainerIDFile(String containerIDFile) {
- checkNotNull(containerIDFile, "no containerIDFile was specified");
- hostConfig.withContainerIDFile(containerIDFile);
+ public CreateContainerCmd withAliases(String... aliases) {
+ this.aliases = Arrays.asList(aliases);
return this;
}
@Override
- public CreateContainerCmd withCpuPeriod(Integer cpuPeriod) {
- checkNotNull(cpuPeriod, "cpuPeriod was not specified");
- hostConfig.withCpuPeriod(cpuPeriod);
+ public CreateContainerCmd withAliases(List aliases) {
+ checkNotNull(aliases, "aliases was not specified");
+ this.aliases = aliases;
return this;
}
- @Override
- public CreateContainerCmd withCpusetCpus(String cpusetCpus) {
- checkNotNull(cpusetCpus, "cpusetCpus was not specified");
- hostConfig.withCpusetCpus(cpusetCpus);
- return this;
- }
@Override
- public CreateContainerCmd withCpusetMems(String cpusetMems) {
- checkNotNull(cpusetMems, "cpusetMems was not specified");
- hostConfig.withCpusetMems(cpusetMems);
- return this;
+ public String[] getCmd() {
+ return cmd;
}
@Override
- public CreateContainerCmd withCpuShares(Integer cpuShares) {
- checkNotNull(cpuShares, "cpuShares was not specified");
- hostConfig.withCpuShares(cpuShares);
+ public CreateContainerCmd withCmd(String... cmd) {
+ checkNotNull(cmd, "cmd was not specified");
+ this.cmd = cmd;
return this;
}
@Override
- public CreateContainerCmd withDevices(Device... devices) {
- checkNotNull(devices, "devices was not specified");
- this.hostConfig.withDevices(devices);
- return this;
+ public CreateContainerCmd withCmd(List cmd) {
+ checkNotNull(cmd, "cmd was not specified");
+ return withCmd(cmd.toArray(new String[0]));
}
- @Override
- public CreateContainerCmd withDevices(List devices) {
- checkNotNull(devices, "devices was not specified");
- return withDevices(devices.toArray(new Device[devices.size()]));
+ @CheckForNull
+ public HealthCheck getHealthcheck() {
+ return healthcheck;
}
- @Override
- public CreateContainerCmd withDns(String... dns) {
- checkNotNull(dns, "dns was not specified");
- this.hostConfig.withDns(dns);
+ public CreateContainerCmdImpl withHealthcheck(HealthCheck healthcheck) {
+ this.healthcheck = healthcheck;
return this;
}
- @Override
- public CreateContainerCmd withDns(List dns) {
- checkNotNull(dns, "dns was not specified");
- return withDns(dns.toArray(new String[dns.size()]));
+ public Boolean getArgsEscaped() {
+ return argsEscaped;
}
- @Override
- public CreateContainerCmd withDnsSearch(String... dnsSearch) {
- checkNotNull(dnsSearch, "dnsSearch was not specified");
- this.hostConfig.withDnsSearch(dnsSearch);
+ public CreateContainerCmdImpl withArgsEscaped(Boolean argsEscaped) {
+ this.argsEscaped = argsEscaped;
return this;
}
@Override
- public CreateContainerCmd withDnsSearch(List dnsSearch) {
- checkNotNull(dnsSearch, "dnsSearch was not specified");
- return withDnsSearch(dnsSearch.toArray(new String[0]));
+ public String getDomainName() {
+ return domainName;
}
@Override
@@ -668,6 +220,11 @@ public CreateContainerCmd withDomainName(String domainName) {
return this;
}
+ @Override
+ public String[] getEntrypoint() {
+ return entrypoint;
+ }
+
@Override
public CreateContainerCmd withEntrypoint(String... entrypoint) {
checkNotNull(entrypoint, "entrypoint was not specified");
@@ -678,7 +235,12 @@ public CreateContainerCmd withEntrypoint(String... entrypoint) {
@Override
public CreateContainerCmd withEntrypoint(List entrypoint) {
checkNotNull(entrypoint, "entrypoint was not specified");
- return withEntrypoint(entrypoint.toArray(new String[entrypoint.size()]));
+ return withEntrypoint(entrypoint.toArray(new String[0]));
+ }
+
+ @Override
+ public String[] getEnv() {
+ return env;
}
@Override
@@ -691,7 +253,13 @@ public CreateContainerCmd withEnv(String... env) {
@Override
public CreateContainerCmd withEnv(List env) {
checkNotNull(env, "env was not specified");
- return withEnv(env.toArray(new String[env.size()]));
+ return withEnv(env.toArray(new String[0]));
+ }
+
+ @Override
+ @JsonIgnore
+ public ExposedPort[] getExposedPorts() {
+ return exposedPorts.getExposedPorts();
}
@Override
@@ -701,6 +269,21 @@ public CreateContainerCmd withExposedPorts(ExposedPort... exposedPorts) {
return this;
}
+ @Override
+ public CreateContainerCmd withExposedPorts(List exposedPorts) {
+ checkNotNull(exposedPorts, "exposedPorts was not specified");
+ return withExposedPorts(exposedPorts.toArray(new ExposedPort[0]));
+ }
+
+ /**
+ * @see #stopSignal
+ */
+ @JsonIgnore
+ @Override
+ public String getStopSignal() {
+ return stopSignal;
+ }
+
@Override
public CreateContainerCmd withStopSignal(String stopSignal) {
checkNotNull(stopSignal, "stopSignal wasn't specified.");
@@ -709,50 +292,44 @@ public CreateContainerCmd withStopSignal(String stopSignal) {
}
@Override
- public CreateContainerCmd withExposedPorts(List exposedPorts) {
- checkNotNull(exposedPorts, "exposedPorts was not specified");
- return withExposedPorts(exposedPorts.toArray(new ExposedPort[exposedPorts.size()]));
+ public Integer getStopTimeout() {
+ return stopTimeout;
}
@Override
- public CreateContainerCmd withExtraHosts(String... extraHosts) {
- checkNotNull(extraHosts, "extraHosts was not specified");
- this.hostConfig.withExtraHosts(extraHosts);
+ public CreateContainerCmd withStopTimeout(Integer stopTimeout) {
+ this.stopTimeout = stopTimeout;
return this;
}
@Override
- public CreateContainerCmd withExtraHosts(List extraHosts) {
- checkNotNull(extraHosts, "extraHosts was not specified");
- return withExtraHosts(extraHosts.toArray(new String[extraHosts.size()]));
+ public String getHostName() {
+ return hostName;
}
@Override
public CreateContainerCmd withHostName(String hostName) {
- checkNotNull(hostConfig, "no hostName was specified");
+ checkNotNull(hostName, "no hostName was specified");
this.hostName = hostName;
return this;
}
@Override
- public CreateContainerCmd withImage(String image) {
- checkNotNull(image, "no image was specified");
- this.image = image;
- return this;
+ public String getImage() {
+ return image;
}
@Override
- public CreateContainerCmd withIpv4Address(String ipv4Address) {
- checkNotNull(ipv4Address, "no ipv4Address was specified");
- this.ipv4Address = ipv4Address;
+ public CreateContainerCmd withImage(String image) {
+ checkNotNull(image, "no image was specified");
+ this.image = image;
return this;
}
@Override
- public CreateContainerCmd withIpv6Address(String ipv6Address) {
- checkNotNull(ipv6Address, "no ipv6Address was specified");
- this.ipv6Address = ipv6Address;
- return this;
+ @JsonIgnore
+ public Map getLabels() {
+ return labels;
}
@Override
@@ -763,146 +340,146 @@ public CreateContainerCmd withLabels(Map labels) {
}
@Override
- public CreateContainerCmd withLinks(Link... links) {
- checkNotNull(links, "links was not specified");
- this.hostConfig.setLinks(links);
+ public String getMacAddress() {
+ return macAddress;
+ }
+
+ @Override
+ public CreateContainerCmd withMacAddress(String macAddress) {
+ checkNotNull(macAddress, "macAddress was not specified");
+ this.macAddress = macAddress;
return this;
}
@Override
- public CreateContainerCmd withLinks(List links) {
- checkNotNull(links, "links was not specified");
- return withLinks(links.toArray(new Link[links.size()]));
+ public String getName() {
+ return name;
}
@Override
- public CreateContainerCmd withLxcConf(LxcConf... lxcConf) {
- checkNotNull(lxcConf, "lxcConf was not specified");
- this.hostConfig.withLxcConf(lxcConf);
+ public CreateContainerCmd withName(String name) {
+ checkNotNull(name, "name was not specified");
+ this.name = name;
return this;
}
@Override
- public CreateContainerCmd withLxcConf(List lxcConf) {
- checkNotNull(lxcConf, "lxcConf was not specified");
- return withLxcConf(lxcConf.toArray(new LxcConf[0]));
+ public String[] getPortSpecs() {
+ return portSpecs;
}
@Override
- public CreateContainerCmd withLogConfig(LogConfig logConfig) {
- checkNotNull(logConfig, "logConfig was not specified");
- this.hostConfig.withLogConfig(logConfig);
+ public CreateContainerCmd withPortSpecs(String... portSpecs) {
+ checkNotNull(portSpecs, "portSpecs was not specified");
+ this.portSpecs = portSpecs;
return this;
}
@Override
- public CreateContainerCmd withMacAddress(String macAddress) {
- checkNotNull(macAddress, "macAddress was not specified");
- this.macAddress = macAddress;
- return this;
+ public CreateContainerCmd withPortSpecs(List portSpecs) {
+ checkNotNull(portSpecs, "portSpecs was not specified");
+ return withPortSpecs(portSpecs.toArray(new String[0]));
}
@Override
- public CreateContainerCmd withMemory(Long memory) {
- checkNotNull(memory, "memory was not specified");
- hostConfig.withMemory(memory);
- return this;
+ public String getUser() {
+ return user;
}
@Override
- public CreateContainerCmd withMemorySwap(Long memorySwap) {
- checkNotNull(memorySwap, "memorySwap was not specified");
- hostConfig.withMemorySwap(memorySwap);
+ public CreateContainerCmd withUser(String user) {
+ checkNotNull(user, "user was not specified");
+ this.user = user;
return this;
}
+
@Override
- public CreateContainerCmd withName(String name) {
- checkNotNull(name, "name was not specified");
- this.name = name;
- return this;
+ public Boolean isAttachStderr() {
+ return attachStderr;
}
@Override
- public CreateContainerCmd withNetworkDisabled(Boolean disableNetwork) {
- checkNotNull(disableNetwork, "disableNetwork was not specified");
- this.networkDisabled = disableNetwork;
+ public CreateContainerCmd withAttachStderr(Boolean attachStderr) {
+ checkNotNull(attachStderr, "attachStderr was not specified");
+ this.attachStderr = attachStderr;
return this;
}
+
@Override
- public CreateContainerCmd withNetworkMode(String networkMode) {
- checkNotNull(networkMode, "networkMode was not specified");
- this.hostConfig.withNetworkMode(networkMode);
- return this;
+ public Boolean isAttachStdin() {
+ return attachStdin;
}
@Override
- public CreateContainerCmd withOomKillDisable(Boolean oomKillDisable) {
- checkNotNull(oomKillDisable, "oomKillDisable was not specified");
- hostConfig.withOomKillDisable(oomKillDisable);
+ public CreateContainerCmd withAttachStdin(Boolean attachStdin) {
+ checkNotNull(attachStdin, "attachStdin was not specified");
+ this.attachStdin = attachStdin;
return this;
}
+
+ @Override
+ public Boolean isAttachStdout() {
+ return attachStdout;
+ }
+
@Override
- public CreateContainerCmd withPortBindings(PortBinding... portBindings) {
- checkNotNull(portBindings, "portBindings was not specified");
- this.hostConfig.withPortBindings(new Ports(portBindings));
+ public CreateContainerCmd withAttachStdout(Boolean attachStdout) {
+ checkNotNull(attachStdout, "attachStdout was not specified");
+ this.attachStdout = attachStdout;
return this;
}
+
@Override
- public CreateContainerCmd withPortBindings(List portBindings) {
- checkNotNull(portBindings, "portBindings was not specified");
- return withPortBindings(portBindings.toArray(new PortBinding[0]));
+ @JsonIgnore
+ public Volume[] getVolumes() {
+ return volumes.getVolumes();
}
@Override
- public CreateContainerCmd withPortBindings(Ports portBindings) {
- checkNotNull(portBindings, "portBindings was not specified");
- this.hostConfig.withPortBindings(portBindings);
+ public CreateContainerCmd withVolumes(Volume... volumes) {
+ checkNotNull(volumes, "volumes was not specified");
+ this.volumes = new Volumes(volumes);
return this;
}
@Override
- public CreateContainerCmd withPortSpecs(String... portSpecs) {
- checkNotNull(portSpecs, "portSpecs was not specified");
- this.portSpecs = portSpecs;
- return this;
+ public CreateContainerCmd withVolumes(List volumes) {
+ checkNotNull(volumes, "volumes was not specified");
+ return withVolumes(volumes.toArray(new Volume[0]));
}
@Override
- public CreateContainerCmd withPortSpecs(List portSpecs) {
- checkNotNull(portSpecs, "portSpecs was not specified");
- return withPortSpecs(portSpecs.toArray(new String[portSpecs.size()]));
+ public String getWorkingDir() {
+ return workingDir;
}
@Override
- public CreateContainerCmd withPrivileged(Boolean privileged) {
- checkNotNull(privileged, "no privileged was specified");
- this.hostConfig.withPrivileged(privileged);
+ public CreateContainerCmd withWorkingDir(String workingDir) {
+ checkNotNull(workingDir, "workingDir was not specified");
+ this.workingDir = workingDir;
return this;
}
@Override
- public CreateContainerCmd withPublishAllPorts(Boolean publishAllPorts) {
- checkNotNull(publishAllPorts, "no publishAllPorts was specified");
- this.hostConfig.withPublishAllPorts(publishAllPorts);
- return this;
+ public Boolean isNetworkDisabled() {
+ return networkDisabled;
}
@Override
- public CreateContainerCmd withReadonlyRootfs(Boolean readonlyRootfs) {
- checkNotNull(readonlyRootfs, "no readonlyRootfs was specified");
- hostConfig.withReadonlyRootfs(readonlyRootfs);
+ public CreateContainerCmd withNetworkDisabled(Boolean disableNetwork) {
+ checkNotNull(disableNetwork, "disableNetwork was not specified");
+ this.networkDisabled = disableNetwork;
return this;
}
+
@Override
- public CreateContainerCmd withRestartPolicy(RestartPolicy restartPolicy) {
- checkNotNull(restartPolicy, "restartPolicy was not specified");
- this.hostConfig.withRestartPolicy(restartPolicy);
- return this;
+ public Boolean isStdInOnce() {
+ return stdInOnce;
}
@Override
@@ -912,6 +489,11 @@ public CreateContainerCmd withStdInOnce(Boolean stdInOnce) {
return this;
}
+ @Override
+ public Boolean isStdinOpen() {
+ return stdinOpen;
+ }
+
@Override
public CreateContainerCmd withStdinOpen(Boolean stdinOpen) {
checkNotNull(stdinOpen, "no stdinOpen was specified");
@@ -919,6 +501,12 @@ public CreateContainerCmd withStdinOpen(Boolean stdinOpen) {
return this;
}
+
+ @Override
+ public Boolean isTty() {
+ return tty;
+ }
+
@Override
public CreateContainerCmd withTty(Boolean tty) {
checkNotNull(tty, "no tty was specified");
@@ -927,78 +515,93 @@ public CreateContainerCmd withTty(Boolean tty) {
}
@Override
- public CreateContainerCmd withUlimits(Ulimit... ulimits) {
- checkNotNull(ulimits, "no ulimits was specified");
- hostConfig.withUlimits(ulimits);
- return this;
+ public HostConfig getHostConfig() {
+ return hostConfig;
}
@Override
- public CreateContainerCmd withUlimits(List ulimits) {
- checkNotNull(ulimits, "no ulimits was specified");
- return withUlimits(ulimits.toArray(new Ulimit[ulimits.size()]));
+ public CreateContainerCmd withHostConfig(HostConfig hostConfig) {
+ this.hostConfig = hostConfig;
+ return this;
}
@Override
- public CreateContainerCmd withUser(String user) {
- checkNotNull(user, "user was not specified");
- this.user = user;
- return this;
+ public String getIpv4Address() {
+ return ipv4Address;
}
@Override
- public CreateContainerCmd withVolumes(Volume... volumes) {
- checkNotNull(volumes, "volumes was not specified");
- this.volumes = new Volumes(volumes);
+ public CreateContainerCmd withIpv4Address(String ipv4Address) {
+ checkNotNull(ipv4Address, "no ipv4Address was specified");
+ this.ipv4Address = ipv4Address;
return this;
}
@Override
- public CreateContainerCmd withVolumes(List volumes) {
- checkNotNull(volumes, "volumes was not specified");
- return withVolumes(volumes.toArray(new Volume[volumes.size()]));
+ public String getIpv6Address() {
+ return ipv6Address;
}
@Override
- public CreateContainerCmd withVolumesFrom(VolumesFrom... volumesFrom) {
- checkNotNull(volumesFrom, "volumesFrom was not specified");
- this.hostConfig.withVolumesFrom(volumesFrom);
+ public CreateContainerCmd withIpv6Address(String ipv6Address) {
+ checkNotNull(ipv6Address, "no ipv6Address was specified");
+ this.ipv6Address = ipv6Address;
return this;
}
- @Override
- public CreateContainerCmd withVolumesFrom(List volumesFrom) {
- checkNotNull(volumesFrom, "volumesFrom was not specified");
- return withVolumesFrom(volumesFrom.toArray(new VolumesFrom[volumesFrom.size()]));
+ @CheckForNull
+ public List getOnBuild() {
+ return onBuild;
}
- @Override
- public CreateContainerCmd withWorkingDir(String workingDir) {
- checkNotNull(workingDir, "workingDir was not specified");
- this.workingDir = workingDir;
+ public CreateContainerCmdImpl withOnBuild(List onBuild) {
+ this.onBuild = onBuild;
return this;
}
+ /**
+ * @throws NotFoundException No such container
+ * @throws ConflictException Named container already exists
+ */
@Override
- public CreateContainerCmd withCgroupParent(final String cgroupParent) {
- checkNotNull(cgroupParent, "cgroupParent was not specified");
- this.hostConfig.withCgroupParent(cgroupParent);
- return this;
- }
+ public CreateContainerResponse exec() throws NotFoundException, ConflictException {
+ //code flow taken from https://github.com/docker/docker/blob/master/runconfig/opts/parse.go
+ ContainerNetwork containerNetwork = null;
- @Override
- public CreateContainerCmd withPidMode(String pidMode) {
- checkNotNull(pidMode, "pidMode was not specified");
- this.hostConfig.withPidMode(pidMode);
- return this;
- }
+ if (ipv4Address != null || ipv6Address != null) {
+ containerNetwork = new ContainerNetwork()
+ .withIpamConfig(new ContainerNetwork.Ipam()
+ .withIpv4Address(ipv4Address)
+ .withIpv6Address(ipv6Address)
+ );
- @Override
- public CreateContainerCmd withHostConfig(HostConfig hostConfig) {
- this.hostConfig = hostConfig;
- return this;
+ }
+
+ if (hostConfig.isUserDefinedNetwork() && hostConfig.getLinks().length > 0) {
+ if (containerNetwork == null) {
+ containerNetwork = new ContainerNetwork();
+ }
+
+ containerNetwork.withLinks(hostConfig.getLinks());
+ }
+
+ if (aliases != null) {
+ if (containerNetwork == null) {
+ containerNetwork = new ContainerNetwork();
+ }
+
+ containerNetwork.withAliases(aliases);
+ }
+
+ if (containerNetwork != null) {
+ networkingConfig = new NetworkingConfig()
+ .withEndpointsConfig(singletonMap(hostConfig.getNetworkMode(), containerNetwork));
+ }
+
+ return super.exec();
}
+
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
diff --git a/src/main/java/com/github/dockerjava/core/command/CreateImageCmdImpl.java b/src/main/java/com/github/dockerjava/core/command/CreateImageCmdImpl.java
index 57ddc2908..9ecf84430 100644
--- a/src/main/java/com/github/dockerjava/core/command/CreateImageCmdImpl.java
+++ b/src/main/java/com/github/dockerjava/core/command/CreateImageCmdImpl.java
@@ -12,7 +12,7 @@
*/
public class CreateImageCmdImpl extends AbstrDockerCmd implements CreateImageCmd {
- private String repository, tag;
+ private String repository, tag, platform;
private InputStream imageStream;
@@ -38,6 +38,11 @@ public String getTag() {
return tag;
}
+ @Override
+ public String getPlatform() {
+ return platform;
+ }
+
@Override
public InputStream getImageStream() {
return imageStream;
@@ -75,4 +80,13 @@ public CreateImageCmdImpl withTag(String tag) {
this.tag = tag;
return this;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public CreateImageCmd withPlatform(String platform) {
+ this.platform = platform;
+ return this;
+ }
}
diff --git a/src/main/java/com/github/dockerjava/core/command/ExecCreateCmdImpl.java b/src/main/java/com/github/dockerjava/core/command/ExecCreateCmdImpl.java
index ed6e58211..ecf208b7e 100644
--- a/src/main/java/com/github/dockerjava/core/command/ExecCreateCmdImpl.java
+++ b/src/main/java/com/github/dockerjava/core/command/ExecCreateCmdImpl.java
@@ -2,6 +2,8 @@
import static com.google.common.base.Preconditions.checkNotNull;
+import java.util.List;
+
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -33,7 +35,7 @@ public class ExecCreateCmdImpl extends AbstrDockerCmd env;
+
+ /**
+ * @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_35}
+ */
+ @JsonProperty("WorkingDir")
+ private String workingDir;
+
public ExecCreateCmdImpl(ExecCreateCmd.Exec exec, String containerId) {
super(exec);
withContainerId(containerId);
@@ -89,12 +103,24 @@ public ExecCreateCmd withCmd(String... cmd) {
return this;
}
+ @Override
+ public ExecCreateCmd withEnv(List env) {
+ this.env = env;
+ return this;
+ }
+
@Override
public ExecCreateCmd withPrivileged(Boolean privileged) {
this.privileged = privileged;
return this;
}
+ @Override
+ public ExecCreateCmd withWorkingDir(String workingDir) {
+ this.workingDir = workingDir;
+ return this;
+ }
+
@Override
public String getContainerId() {
return containerId;
@@ -120,6 +146,11 @@ public Boolean hasTtyEnabled() {
return tty;
}
+ @Override
+ public List getEnv() {
+ return env;
+ }
+
@Override
public Boolean getPrivileged() {
return privileged;
@@ -130,6 +161,11 @@ public String getUser() {
return user;
}
+ @Override
+ public String getWorkingDir() {
+ return workingDir;
+ }
+
/**
* @throws NotFoundException
* No such container
diff --git a/src/main/java/com/github/dockerjava/core/command/ListNetworksCmdImpl.java b/src/main/java/com/github/dockerjava/core/command/ListNetworksCmdImpl.java
index 44a9d2cfb..65c13e255 100644
--- a/src/main/java/com/github/dockerjava/core/command/ListNetworksCmdImpl.java
+++ b/src/main/java/com/github/dockerjava/core/command/ListNetworksCmdImpl.java
@@ -4,9 +4,12 @@
import com.github.dockerjava.api.model.Network;
import com.github.dockerjava.core.util.FiltersBuilder;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
+import static com.google.common.base.Preconditions.checkNotNull;
+
public class ListNetworksCmdImpl extends AbstrDockerCmd> implements ListNetworksCmd {
private FiltersBuilder filtersBuilder = new FiltersBuilder();
@@ -31,4 +34,11 @@ public ListNetworksCmd withNameFilter(String... networkName) {
this.filtersBuilder.withFilter("name", networkName);
return this;
}
+
+ @Override
+ public ListNetworksCmd withFilter(String filterName, Collection filterValues) {
+ checkNotNull(filterValues, filterName + " was not specified");
+ this.filtersBuilder.withFilter(filterName, filterValues);
+ return this;
+ }
}
diff --git a/src/main/java/com/github/dockerjava/core/command/ListVolumesCmdImpl.java b/src/main/java/com/github/dockerjava/core/command/ListVolumesCmdImpl.java
index d9efe7b17..b3a18d776 100644
--- a/src/main/java/com/github/dockerjava/core/command/ListVolumesCmdImpl.java
+++ b/src/main/java/com/github/dockerjava/core/command/ListVolumesCmdImpl.java
@@ -2,6 +2,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -33,4 +34,11 @@ public ListVolumesCmd withDanglingFilter(Boolean dangling) {
this.filters.withFilter("dangling", dangling.toString());
return this;
}
+
+ @Override
+ public ListVolumesCmd withFilter(String filterName, Collection filterValues) {
+ checkNotNull(filterValues, filterName + " was not specified");
+ this.filters.withFilter(filterName, filterValues);
+ return this;
+ }
}
diff --git a/src/main/java/com/github/dockerjava/core/command/PruneCmdImpl.java b/src/main/java/com/github/dockerjava/core/command/PruneCmdImpl.java
new file mode 100644
index 000000000..a191099ed
--- /dev/null
+++ b/src/main/java/com/github/dockerjava/core/command/PruneCmdImpl.java
@@ -0,0 +1,102 @@
+package com.github.dockerjava.core.command;
+
+import com.github.dockerjava.api.command.PruneCmd;
+import com.github.dockerjava.api.model.PruneResponse;
+import com.github.dockerjava.api.model.PruneType;
+import com.github.dockerjava.core.util.FiltersBuilder;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+import java.util.List;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Delete unused content (containers, images, volumes, networks, build relicts)
+ */
+public class PruneCmdImpl extends AbstrDockerCmd implements PruneCmd {
+
+ private static final String BUILD_API_PATH = "/build/prune";
+ private static final String CONTAINERS_API_PATH = "/containers/prune";
+ private static final String IMAGES_API_PATH = "/images/prune";
+ private static final String VOLUMES_API_PATH = "/volumes/prune";
+ private static final String NETWORKS_API_PATH = "/networks/prune";
+
+ private FiltersBuilder filters = new FiltersBuilder();
+ private PruneType pruneType;
+
+ public PruneCmdImpl(Exec exec, PruneType pruneType) {
+ super(exec);
+ this.pruneType = pruneType;
+ }
+
+ @Nonnull
+ @Override
+ public PruneType getPruneType() {
+ return pruneType;
+ }
+
+ @Nonnull
+ @Override
+ public String getApiPath() {
+ String apiPath;
+ switch (getPruneType()) {
+ case BUILD:
+ apiPath = BUILD_API_PATH;
+ break;
+ case IMAGES:
+ apiPath = IMAGES_API_PATH;
+ break;
+ case NETWORKS:
+ apiPath = NETWORKS_API_PATH;
+ break;
+ case VOLUMES:
+ apiPath = VOLUMES_API_PATH;
+ break;
+ default:
+ apiPath = CONTAINERS_API_PATH;
+ break;
+ }
+ return apiPath;
+ }
+
+ @CheckForNull
+ @Override
+ public Map> getFilters() {
+ return filters.build();
+ }
+
+ @Override
+ public PruneCmd withPruneType(final PruneType pruneType) {
+ checkNotNull(pruneType, "pruneType has not been specified");
+ this.pruneType = pruneType;
+ return this;
+ }
+
+ @Override
+ public PruneCmd withDangling(Boolean dangling) {
+ checkNotNull(dangling, "dangling has not been specified");
+ filters.withFilter("dangling", dangling ? "1" : "0");
+ return this;
+ }
+
+ @Override
+ public PruneCmd withUntilFilter(final String until) {
+ checkNotNull(until, "until has not been specified");
+ filters.withUntil(until);
+ return this;
+ }
+
+ @Override
+ public PruneCmd withLabelFilter(final String... labels) {
+ checkNotNull(labels, "labels have not been specified");
+ filters.withLabels(labels);
+ return this;
+ }
+
+ @Override
+ public PruneResponse exec() {
+ return super.exec();
+ }
+}
diff --git a/src/main/java/com/github/dockerjava/core/command/PullImageCmdImpl.java b/src/main/java/com/github/dockerjava/core/command/PullImageCmdImpl.java
index b69791fe5..a3395c21b 100644
--- a/src/main/java/com/github/dockerjava/core/command/PullImageCmdImpl.java
+++ b/src/main/java/com/github/dockerjava/core/command/PullImageCmdImpl.java
@@ -13,7 +13,7 @@
*/
public class PullImageCmdImpl extends AbstrAsyncDockerCmd implements PullImageCmd {
- private String repository, tag, registry;
+ private String repository, tag, platform, registry;
private AuthConfig authConfig;
@@ -42,6 +42,11 @@ public String getTag() {
return tag;
}
+ @Override
+ public String getPlatform() {
+ return platform;
+ }
+
@Override
public String getRegistry() {
return registry;
@@ -61,6 +66,12 @@ public PullImageCmd withTag(String tag) {
return this;
}
+ @Override
+ public PullImageCmd withPlatform(String platform) {
+ this.platform = platform;
+ return this;
+ }
+
@Override
public PullImageCmd withRegistry(String registry) {
checkNotNull(registry, "registry was not specified");
diff --git a/src/main/java/com/github/dockerjava/core/dockerfile/Dockerfile.java b/src/main/java/com/github/dockerjava/core/dockerfile/Dockerfile.java
index c9931efbd..11ed5fc4e 100644
--- a/src/main/java/com/github/dockerjava/core/dockerfile/Dockerfile.java
+++ b/src/main/java/com/github/dockerjava/core/dockerfile/Dockerfile.java
@@ -205,12 +205,10 @@ private void addFilesInDirectory(File directory) {
if (files.length != 0) {
for (File f : files) {
- if (effectiveMatchingIgnorePattern(f) == null) {
- if (f.isDirectory()) {
- addFilesInDirectory(f);
- } else {
- filesToAdd.add(f);
- }
+ if (f.isDirectory()) {
+ addFilesInDirectory(f);
+ } else if (effectiveMatchingIgnorePattern(f) == null) {
+ filesToAdd.add(f);
}
}
// base directory should at least contains Dockerfile, but better check
diff --git a/src/main/java/com/github/dockerjava/core/exec/AbstrDockerCmdExec.java b/src/main/java/com/github/dockerjava/core/exec/AbstrDockerCmdExec.java
index 9b28ddd75..1ec333416 100644
--- a/src/main/java/com/github/dockerjava/core/exec/AbstrDockerCmdExec.java
+++ b/src/main/java/com/github/dockerjava/core/exec/AbstrDockerCmdExec.java
@@ -5,11 +5,13 @@
import com.github.dockerjava.api.model.AuthConfig;
import com.github.dockerjava.api.model.AuthConfigurations;
import com.github.dockerjava.core.DockerClientConfig;
-import com.github.dockerjava.core.RemoteApiVersion;
import com.github.dockerjava.core.InvocationBuilder;
+import com.github.dockerjava.core.RemoteApiVersion;
import com.github.dockerjava.core.WebTarget;
-import org.apache.commons.codec.binary.Base64;
+import com.google.common.io.BaseEncoding;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
import java.io.IOException;
import static com.github.dockerjava.core.RemoteApiVersion.UNKNOWN_VERSION;
@@ -33,19 +35,21 @@ protected WebTarget getBaseResource() {
return baseResource;
}
+ @CheckForNull
protected AuthConfigurations getBuildAuthConfigs() {
return dockerClientConfig.getAuthConfigurations();
}
- protected String registryAuth(AuthConfig authConfig) {
+ protected String registryAuth(@Nonnull AuthConfig authConfig) {
try {
- return Base64.encodeBase64String(new ObjectMapper().writeValueAsString(authConfig).getBytes());
+ return BaseEncoding.base64Url().encode(new ObjectMapper().writeValueAsString(authConfig).getBytes());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
- protected String registryConfigs(AuthConfigurations authConfigs) {
+ @Nonnull
+ protected String registryConfigs(@Nonnull AuthConfigurations authConfigs) {
try {
final String json;
final ObjectMapper objectMapper = new ObjectMapper();
@@ -61,18 +65,21 @@ protected String registryConfigs(AuthConfigurations authConfigs) {
} else {
json = objectMapper.writeValueAsString(authConfigs);
}
-
- return Base64.encodeBase64String(json.getBytes());
+ return BaseEncoding.base64Url().encode(json.getBytes());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
- protected InvocationBuilder resourceWithAuthConfig(AuthConfig authConfig, InvocationBuilder request) {
+ @Nonnull
+ protected InvocationBuilder resourceWithAuthConfig(@Nonnull AuthConfig authConfig,
+ @Nonnull InvocationBuilder request) {
return request.header("X-Registry-Auth", registryAuth(authConfig));
}
- protected InvocationBuilder resourceWithOptionalAuthConfig(AuthConfig authConfig, InvocationBuilder request) {
+ @Nonnull
+ protected InvocationBuilder resourceWithOptionalAuthConfig(@CheckForNull AuthConfig authConfig,
+ @Nonnull InvocationBuilder request) {
if (authConfig != null) {
request = resourceWithAuthConfig(authConfig, request);
}
diff --git a/src/main/java/com/github/dockerjava/core/exec/BuildImageCmdExec.java b/src/main/java/com/github/dockerjava/core/exec/BuildImageCmdExec.java
index 9d749ae44..1a8cd37e5 100644
--- a/src/main/java/com/github/dockerjava/core/exec/BuildImageCmdExec.java
+++ b/src/main/java/com/github/dockerjava/core/exec/BuildImageCmdExec.java
@@ -1,8 +1,5 @@
package com.github.dockerjava.core.exec;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.fasterxml.jackson.core.type.TypeReference;
import com.github.dockerjava.api.async.ResultCallback;
import com.github.dockerjava.api.command.BuildImageCmd;
@@ -12,7 +9,12 @@
import com.github.dockerjava.core.InvocationBuilder;
import com.github.dockerjava.core.MediaType;
import com.github.dockerjava.core.WebTarget;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import javax.annotation.CheckForNull;
+
+import static com.github.dockerjava.core.util.CacheFromEncoder.jsonEncode;
import static org.apache.commons.lang.StringUtils.isNotBlank;
public class BuildImageCmdExec extends AbstrAsyncDockerCmdExec implements
@@ -31,8 +33,9 @@ private InvocationBuilder resourceWithOptionalAuthConfig(BuildImageCmd command,
return request;
}
- private static AuthConfigurations firstNonNull(final AuthConfigurations fromCommand,
- final AuthConfigurations fromConfig) {
+ @CheckForNull
+ private static AuthConfigurations firstNonNull(@CheckForNull final AuthConfigurations fromCommand,
+ @CheckForNull final AuthConfigurations fromConfig) {
if (fromCommand != null) {
return fromCommand;
}
@@ -59,7 +62,7 @@ protected Void execute0(BuildImageCmd command, ResultCallback
}
if (command.getCacheFrom() != null && !command.getCacheFrom().isEmpty()) {
- webTarget = webTarget.queryParamsSet("cachefrom", command.getCacheFrom());
+ webTarget = webTarget.queryParam("cachefrom", jsonEncode(command.getCacheFrom()));
}
if (command.getRemote() != null) {
@@ -106,6 +109,14 @@ protected Void execute0(BuildImageCmd command, ResultCallback
webTarget = webTarget.queryParam("networkmode", command.getNetworkMode());
}
+ if (command.getPlatform() != null) {
+ webTarget = webTarget.queryParam("platform", command.getPlatform());
+ }
+
+ if (command.getTarget() != null) {
+ webTarget = webTarget.queryParam("target", command.getTarget());
+ }
+
LOGGER.trace("POST: {}", webTarget);
InvocationBuilder builder = resourceWithOptionalAuthConfig(command, webTarget.request())
diff --git a/src/main/java/com/github/dockerjava/core/exec/CreateImageCmdExec.java b/src/main/java/com/github/dockerjava/core/exec/CreateImageCmdExec.java
index ad3d0d283..b1f4f23c0 100644
--- a/src/main/java/com/github/dockerjava/core/exec/CreateImageCmdExec.java
+++ b/src/main/java/com/github/dockerjava/core/exec/CreateImageCmdExec.java
@@ -24,6 +24,10 @@ protected CreateImageResponse execute(CreateImageCmd command) {
WebTarget webResource = getBaseResource().path("/images/create").queryParam("repo", command.getRepository())
.queryParam("tag", command.getTag()).queryParam("fromSrc", "-");
+ if (command.getPlatform() != null) {
+ webResource = webResource.queryParam("platform", command.getPlatform());
+ }
+
LOGGER.trace("POST: {}", webResource);
return webResource.request().accept(MediaType.APPLICATION_OCTET_STREAM)
.post(new TypeReference() {
diff --git a/src/main/java/com/github/dockerjava/core/exec/PruneCmdExec.java b/src/main/java/com/github/dockerjava/core/exec/PruneCmdExec.java
new file mode 100644
index 000000000..0b8832bcb
--- /dev/null
+++ b/src/main/java/com/github/dockerjava/core/exec/PruneCmdExec.java
@@ -0,0 +1,40 @@
+package com.github.dockerjava.core.exec;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.github.dockerjava.api.command.PruneCmd;
+import com.github.dockerjava.api.model.PruneResponse;
+import com.github.dockerjava.core.DockerClientConfig;
+import com.github.dockerjava.core.MediaType;
+import com.github.dockerjava.core.WebTarget;
+import com.github.dockerjava.core.util.FiltersEncoder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PruneCmdExec extends AbstrSyncDockerCmdExec implements PruneCmd.Exec {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PruneCmdExec.class);
+
+
+ public PruneCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) {
+ super(baseResource, dockerClientConfig);
+ }
+
+ @Override
+ protected PruneResponse execute(PruneCmd command) {
+ WebTarget webTarget = getBaseResource().path(command.getApiPath());
+
+ if (command.getFilters() != null && !command.getFilters().isEmpty()) {
+ webTarget = webTarget.queryParam("filters", FiltersEncoder.jsonEncode(command.getFilters()));
+ }
+
+ LOGGER.trace("POST: {}", webTarget);
+
+ PruneResponse response = webTarget.request().accept(MediaType.APPLICATION_JSON)
+ .post(null, new TypeReference() { });
+
+ LOGGER.trace("Response: {}", response);
+
+ return response;
+ }
+
+}
diff --git a/src/main/java/com/github/dockerjava/core/exec/PullImageCmdExec.java b/src/main/java/com/github/dockerjava/core/exec/PullImageCmdExec.java
index a6079d7eb..1ba0fd8c2 100644
--- a/src/main/java/com/github/dockerjava/core/exec/PullImageCmdExec.java
+++ b/src/main/java/com/github/dockerjava/core/exec/PullImageCmdExec.java
@@ -25,9 +25,14 @@ protected Void execute0(PullImageCmd command, ResultCallback r
WebTarget webResource = getBaseResource().path("/images/create").queryParam("tag", command.getTag())
.queryParam("fromImage", command.getRepository()).queryParam("registry", command.getRegistry());
+ if (command.getPlatform() != null) {
+ webResource = webResource.queryParam("platform", command.getPlatform());
+ }
+
LOGGER.trace("POST: {}", webResource);
- resourceWithOptionalAuthConfig(command.getAuthConfig(), webResource.request()).accept(MediaType.APPLICATION_OCTET_STREAM).post(
- null, new TypeReference() {
+ resourceWithOptionalAuthConfig(command.getAuthConfig(), webResource.request())
+ .accept(MediaType.APPLICATION_OCTET_STREAM)
+ .post(null, new TypeReference() {
}, resultCallback);
return null;
diff --git a/src/main/java/com/github/dockerjava/core/exec/SaveImageCmdExec.java b/src/main/java/com/github/dockerjava/core/exec/SaveImageCmdExec.java
index d79d3539a..94001bd5c 100644
--- a/src/main/java/com/github/dockerjava/core/exec/SaveImageCmdExec.java
+++ b/src/main/java/com/github/dockerjava/core/exec/SaveImageCmdExec.java
@@ -1,14 +1,14 @@
package com.github.dockerjava.core.exec;
-import java.io.InputStream;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.github.dockerjava.api.command.SaveImageCmd;
import com.github.dockerjava.core.DockerClientConfig;
import com.github.dockerjava.core.MediaType;
import com.github.dockerjava.core.WebTarget;
+import com.google.common.base.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.InputStream;
public class SaveImageCmdExec extends AbstrSyncDockerCmdExec implements SaveImageCmd.Exec {
private static final Logger LOGGER = LoggerFactory.getLogger(SaveImageCmdExec.class);
@@ -19,8 +19,14 @@ public SaveImageCmdExec(WebTarget baseResource, DockerClientConfig dockerClientC
@Override
protected InputStream execute(SaveImageCmd command) {
- WebTarget webResource = getBaseResource().path("/images/" + command.getName() + "/get").queryParam("tag",
- command.getTag());
+
+ String name = command.getName();
+ if (!Strings.isNullOrEmpty(command.getTag())) {
+ name += ":" + command.getTag();
+ }
+
+ WebTarget webResource = getBaseResource().
+ path("/images/" + name + "/get");
LOGGER.trace("GET: {}", webResource);
return webResource.request().accept(MediaType.APPLICATION_JSON).get();
diff --git a/src/main/java/com/github/dockerjava/core/util/CacheFromEncoder.java b/src/main/java/com/github/dockerjava/core/util/CacheFromEncoder.java
new file mode 100644
index 000000000..2a24f76ae
--- /dev/null
+++ b/src/main/java/com/github/dockerjava/core/util/CacheFromEncoder.java
@@ -0,0 +1,28 @@
+package com.github.dockerjava.core.util;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
+
+import javax.ws.rs.core.MediaType;
+import java.util.Collection;
+
+/**
+ * JSON Encoder for the docker --cache-from parameter.
+ */
+public class CacheFromEncoder {
+
+ private CacheFromEncoder() {
+ }
+
+ private static final ObjectMapper MAPPER = new JacksonJaxbJsonProvider().locateMapper(Collection.class,
+ MediaType.APPLICATION_JSON_TYPE);
+
+ public static String jsonEncode(Collection imageIds) {
+ try {
+ return MAPPER.writeValueAsString(imageIds);
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/src/main/java/com/github/dockerjava/core/util/FiltersBuilder.java b/src/main/java/com/github/dockerjava/core/util/FiltersBuilder.java
index 0c414f983..d942e59e0 100644
--- a/src/main/java/com/github/dockerjava/core/util/FiltersBuilder.java
+++ b/src/main/java/com/github/dockerjava/core/util/FiltersBuilder.java
@@ -1,5 +1,7 @@
package com.github.dockerjava.core.util;
+import com.google.common.base.Strings;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -7,6 +9,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.regex.Pattern;
/**
* Representation of Docker filters.
@@ -16,6 +19,14 @@
*/
public class FiltersBuilder {
+ private static final Pattern UNTIL_TIMESTAMP_PATTERN =
+ Pattern.compile("^\\d{1,10}$");
+ private static final Pattern UNTIL_DATETIME_PATTERN =
+ Pattern.compile("^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])([Tt]([01][0-9]|2[0-3]):([0-5][0-9]):"
+ + "([0-5][0-9]|60)(\\.[0-9]+)?)?(([Zz])|([\\+|\\-]([01][0-9]|2[0-3]):[0-5][0-9]))?$");
+ private static final Pattern UNTIL_GO_PATTERN =
+ Pattern.compile("^([1-9][0-9]*h)?([1-9][0-9]*m)?([1-9][0-9]*s)?$");
+
private Map> filters = new HashMap>();
public FiltersBuilder() {
@@ -75,6 +86,14 @@ public FiltersBuilder withLabels(Map labels) {
return this;
}
+ public FiltersBuilder withUntil(String until) throws NumberFormatException {
+ if (!isValidUntil(until)) {
+ throw new NumberFormatException("Not valid format of 'until': " + until);
+ }
+
+ return withFilter("until", until);
+ }
+
private static List labelsMapToList(Map labels) {
List result = new ArrayList();
for (Entry entry : labels.entrySet()) {
@@ -87,6 +106,18 @@ private static List labelsMapToList(Map labels) {
return result;
}
+ private boolean isValidUntil(String until) {
+ if (UNTIL_DATETIME_PATTERN.matcher(until).matches()) {
+ return true;
+ } else if (!Strings.isNullOrEmpty(until) && UNTIL_GO_PATTERN.matcher(until).matches()) {
+ return true;
+ } else if (UNTIL_TIMESTAMP_PATTERN.matcher(until).matches()) {
+ return true;
+ }
+
+ return false;
+ }
+
// CHECKSTYLE:OFF
@Override
public boolean equals(Object o) {
diff --git a/src/main/java/com/github/dockerjava/core/util/FiltersEncoder.java b/src/main/java/com/github/dockerjava/core/util/FiltersEncoder.java
index 280daad45..7b1e34f74 100644
--- a/src/main/java/com/github/dockerjava/core/util/FiltersEncoder.java
+++ b/src/main/java/com/github/dockerjava/core/util/FiltersEncoder.java
@@ -3,30 +3,27 @@
import java.util.List;
import java.util.Map;
-import javax.ws.rs.core.MediaType;
-
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
/**
* JSON Encoder for docker filters.
*
* @author Carlos Sanchez
- *
*/
public class FiltersEncoder {
+
private FiltersEncoder() {
}
- private static final ObjectMapper OBJECT_MAPPER = new JacksonJaxbJsonProvider().locateMapper(Map.class,
- MediaType.APPLICATION_JSON_TYPE);
+ private static final ObjectMapper MAPPER = new ObjectMapper();
- public static String jsonEncode(Map> filters) {
+ public static String jsonEncode(Map> mapStringListString) {
try {
- return OBJECT_MAPPER.writeValueAsString(filters);
+ return MAPPER.writeValueAsString(mapStringListString);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
+
}
diff --git a/src/main/java/com/github/dockerjava/core/util/ServiceFiltersBuilder.java b/src/main/java/com/github/dockerjava/core/util/ServiceFiltersBuilder.java
deleted file mode 100644
index db52df73f..000000000
--- a/src/main/java/com/github/dockerjava/core/util/ServiceFiltersBuilder.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.github.dockerjava.core.util;
-
-import org.apache.commons.lang.builder.EqualsBuilder;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Representation of filters to service lists.
- */
-@Deprecated
-public class ServiceFiltersBuilder {
-
- private Map> filters = new HashMap<>();
-
- public ServiceFiltersBuilder() {
- }
-
- public ServiceFiltersBuilder withFilter(String key, String... value) {
- filters.put(key, Arrays.asList(value));
- return this;
- }
-
- public ServiceFiltersBuilder withFilter(String key, List value) {
- filters.put(key, value);
- return this;
- }
-
- public List getFilter(String key) {
- return filters.get(key);
- }
-
- public ServiceFiltersBuilder withIds(List ids) {
- withFilter("id", ids);
- return this;
- }
-
- public List getIds() {
- return getFilter("id");
- }
-
- public ServiceFiltersBuilder withNames(List names) {
- withFilter("name", names);
- return this;
- }
-
- public List getNames() {
- return getFilter("names");
- }
-
- @Override
- public boolean equals(Object o) {
- return EqualsBuilder.reflectionEquals(this, o);
-
- }
-
- @Override
- public int hashCode() {
- return filters.hashCode();
- }
-
- public Map> build() {
- return filters;
- }
-}
diff --git a/src/main/java/com/github/dockerjava/jaxrs/AbstrDockerCmdExec.java b/src/main/java/com/github/dockerjava/jaxrs/AbstrDockerCmdExec.java
index e5852f5ea..47681e20c 100644
--- a/src/main/java/com/github/dockerjava/jaxrs/AbstrDockerCmdExec.java
+++ b/src/main/java/com/github/dockerjava/jaxrs/AbstrDockerCmdExec.java
@@ -6,7 +6,7 @@
import com.github.dockerjava.api.model.AuthConfigurations;
import com.github.dockerjava.core.DockerClientConfig;
import com.github.dockerjava.core.RemoteApiVersion;
-import org.apache.commons.codec.binary.Base64;
+import com.google.common.io.BaseEncoding;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
@@ -39,7 +39,7 @@ protected AuthConfigurations getBuildAuthConfigs() {
protected String registryAuth(AuthConfig authConfig) {
try {
- return Base64.encodeBase64String(new ObjectMapper().writeValueAsString(authConfig).getBytes());
+ return BaseEncoding.base64Url().encode(new ObjectMapper().writeValueAsString(authConfig).getBytes());
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -74,7 +74,7 @@ protected String registryConfigs(AuthConfigurations authConfigs) {
json = objectMapper.writeValueAsString(authConfigs);
}
- return Base64.encodeBase64String(json.getBytes());
+ return BaseEncoding.base64Url().encode(json.getBytes());
} catch (IOException e) {
throw new RuntimeException(e);
}
diff --git a/src/main/java/com/github/dockerjava/jaxrs/BuildImageCmdExec.java b/src/main/java/com/github/dockerjava/jaxrs/BuildImageCmdExec.java
index 53f31050a..49d83eaf9 100644
--- a/src/main/java/com/github/dockerjava/jaxrs/BuildImageCmdExec.java
+++ b/src/main/java/com/github/dockerjava/jaxrs/BuildImageCmdExec.java
@@ -9,6 +9,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.dockerjava.core.util.CacheFromEncoder;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.RequestEntityProcessing;
import org.slf4j.Logger;
@@ -75,10 +76,8 @@ protected AbstractCallbackNotifier callbackNotifier(BuildImag
webTarget = webTarget.queryParam("t", command.getTag());
}
- if (command.getCacheFrom() != null) {
- for (String c: command.getCacheFrom()) {
- webTarget = webTarget.queryParam("cachefrom", c);
- }
+ if (command.getCacheFrom() != null && !command.getCacheFrom().isEmpty()) {
+ webTarget = webTarget.queryParam("cachefrom", CacheFromEncoder.jsonEncode(command.getCacheFrom()));
}
if (command.getRemote() != null) {
@@ -125,6 +124,14 @@ protected AbstractCallbackNotifier callbackNotifier(BuildImag
webTarget = webTarget.queryParam("networkmode", command.getNetworkMode());
}
+ if (command.getPlatform() != null) {
+ webTarget = webTarget.queryParam("platform", command.getPlatform());
+ }
+
+ if (command.getTarget() != null) {
+ webTarget = webTarget.queryParam("target", command.getTarget());
+ }
+
webTarget.property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.CHUNKED);
webTarget.property(ClientProperties.CHUNKED_ENCODING_SIZE, 1024 * 1024);
diff --git a/src/main/java/com/github/dockerjava/jaxrs/CreateImageCmdExec.java b/src/main/java/com/github/dockerjava/jaxrs/CreateImageCmdExec.java
index d5c40f83b..dc1c9e1af 100644
--- a/src/main/java/com/github/dockerjava/jaxrs/CreateImageCmdExec.java
+++ b/src/main/java/com/github/dockerjava/jaxrs/CreateImageCmdExec.java
@@ -26,6 +26,10 @@ protected CreateImageResponse execute(CreateImageCmd command) {
WebTarget webResource = getBaseResource().path("/images/create").queryParam("repo", command.getRepository())
.queryParam("tag", command.getTag()).queryParam("fromSrc", "-");
+ if (command.getPlatform() != null) {
+ webResource = webResource.queryParam("platform", command.getPlatform());
+ }
+
LOGGER.trace("POST: {}", webResource);
return webResource.request().accept(MediaType.APPLICATION_OCTET_STREAM_TYPE)
.post(entity(command.getImageStream(), MediaType.APPLICATION_OCTET_STREAM), CreateImageResponse.class);
diff --git a/src/main/java/com/github/dockerjava/jaxrs/JerseyDockerCmdExecFactory.java b/src/main/java/com/github/dockerjava/jaxrs/JerseyDockerCmdExecFactory.java
index 5712163d1..1582d5313 100644
--- a/src/main/java/com/github/dockerjava/jaxrs/JerseyDockerCmdExecFactory.java
+++ b/src/main/java/com/github/dockerjava/jaxrs/JerseyDockerCmdExecFactory.java
@@ -47,6 +47,7 @@
import com.github.dockerjava.api.command.LogSwarmObjectCmd;
import com.github.dockerjava.api.command.PauseContainerCmd;
import com.github.dockerjava.api.command.PingCmd;
+import com.github.dockerjava.api.command.PruneCmd;
import com.github.dockerjava.api.command.PullImageCmd;
import com.github.dockerjava.api.command.PushImageCmd;
import com.github.dockerjava.api.command.RemoveContainerCmd;
@@ -658,6 +659,11 @@ public ListTasksCmd.Exec listTasksCmdExec() {
return new ListTasksCmdExec(getBaseResource(), getDockerClientConfig());
}
+ @Override
+ public PruneCmd.Exec pruneCmdExec() {
+ return new PruneCmdExec(getBaseResource(), getDockerClientConfig());
+ }
+
@Override
public void close() throws IOException {
checkNotNull(client, "Factory not initialized. You probably forgot to call init()!");
diff --git a/src/main/java/com/github/dockerjava/jaxrs/PruneCmdExec.java b/src/main/java/com/github/dockerjava/jaxrs/PruneCmdExec.java
new file mode 100644
index 000000000..324bc8201
--- /dev/null
+++ b/src/main/java/com/github/dockerjava/jaxrs/PruneCmdExec.java
@@ -0,0 +1,41 @@
+package com.github.dockerjava.jaxrs;
+
+import com.github.dockerjava.api.command.PruneCmd;
+import com.github.dockerjava.api.model.PruneResponse;
+import com.github.dockerjava.core.DockerClientConfig;
+import com.github.dockerjava.core.util.FiltersEncoder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
+
+import static com.google.common.net.UrlEscapers.urlPathSegmentEscaper;
+
+public class PruneCmdExec extends AbstrSyncDockerCmdExec implements PruneCmd.Exec {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PruneCmdExec.class);
+
+ public PruneCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) {
+ super(baseResource, dockerClientConfig);
+ }
+
+ @Override
+ protected PruneResponse execute(PruneCmd command) {
+ WebTarget webTarget = getBaseResource().path(command.getApiPath());
+
+ if (command.getFilters() != null && !command.getFilters().isEmpty()) {
+ webTarget = webTarget.queryParam("filters", urlPathSegmentEscaper().escape(FiltersEncoder.jsonEncode(command.getFilters())));
+ }
+
+ LOGGER.trace("POST: {}", webTarget);
+
+ PruneResponse response = webTarget.request().accept(MediaType.APPLICATION_JSON)
+ .post(null, new GenericType() { });
+ LOGGER.trace("Response: {}", response);
+
+ return response;
+ }
+
+}
diff --git a/src/main/java/com/github/dockerjava/jaxrs/PullImageCmdExec.java b/src/main/java/com/github/dockerjava/jaxrs/PullImageCmdExec.java
index d2b22856d..70e1d0aac 100644
--- a/src/main/java/com/github/dockerjava/jaxrs/PullImageCmdExec.java
+++ b/src/main/java/com/github/dockerjava/jaxrs/PullImageCmdExec.java
@@ -32,6 +32,10 @@ protected AbstractCallbackNotifier callbackNotifier(PullImageC
WebTarget webResource = getBaseResource().path("/images/create").queryParam("tag", command.getTag())
.queryParam("fromImage", command.getRepository()).queryParam("registry", command.getRegistry());
+ if (command.getPlatform() != null) {
+ webResource = webResource.queryParam("platform", command.getPlatform());
+ }
+
LOGGER.trace("POST: {}", webResource);
Builder builder = resourceWithOptionalAuthConfig(command.getAuthConfig(), webResource.request()).accept(
MediaType.APPLICATION_OCTET_STREAM_TYPE);
diff --git a/src/main/java/com/github/dockerjava/jaxrs/SaveImageCmdExec.java b/src/main/java/com/github/dockerjava/jaxrs/SaveImageCmdExec.java
index f3f9a0d35..c386ea3a0 100644
--- a/src/main/java/com/github/dockerjava/jaxrs/SaveImageCmdExec.java
+++ b/src/main/java/com/github/dockerjava/jaxrs/SaveImageCmdExec.java
@@ -12,6 +12,7 @@
import com.github.dockerjava.api.command.SaveImageCmd;
import com.github.dockerjava.core.DockerClientConfig;
import com.github.dockerjava.jaxrs.util.WrappedResponseInputStream;
+import com.google.common.base.Strings;
public class SaveImageCmdExec extends AbstrSyncDockerCmdExec implements SaveImageCmd.Exec {
private static final Logger LOGGER = LoggerFactory.getLogger(SaveImageCmdExec.class);
@@ -22,8 +23,13 @@ public SaveImageCmdExec(WebTarget baseResource, DockerClientConfig dockerClientC
@Override
protected InputStream execute(SaveImageCmd command) {
- WebTarget webResource = getBaseResource().path("/images/" + command.getName() + "/get").queryParam("tag",
- command.getTag());
+ // If tag is present, only tar the specific image
+ // else tar all the images with the same name
+ String name = command.getName();
+ if (!Strings.isNullOrEmpty(command.getTag())) {
+ name += ":" + command.getTag();
+ }
+ WebTarget webResource = getBaseResource().path("/images/" + name + "/get");
LOGGER.trace("GET: {}", webResource);
Response response = webResource.request().accept(MediaType.APPLICATION_JSON).get();
diff --git a/src/main/java/com/github/dockerjava/netty/NettyDockerCmdExecFactory.java b/src/main/java/com/github/dockerjava/netty/NettyDockerCmdExecFactory.java
index 5e63921e1..dfc740e35 100644
--- a/src/main/java/com/github/dockerjava/netty/NettyDockerCmdExecFactory.java
+++ b/src/main/java/com/github/dockerjava/netty/NettyDockerCmdExecFactory.java
@@ -39,6 +39,7 @@
import io.netty.channel.unix.DomainSocketAddress;
import io.netty.channel.unix.UnixChannel;
import io.netty.handler.codec.http.HttpClientCodec;
+import io.netty.handler.codec.http.HttpContentDecompressor;
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.ssl.SslHandler;
import io.netty.handler.timeout.IdleState;
@@ -158,6 +159,7 @@ public EpollDomainSocketChannel newChannel() {
@Override
protected void initChannel(final UnixChannel channel) throws Exception {
channel.pipeline().addLast(new HttpClientCodec());
+ channel.pipeline().addLast(new HttpContentDecompressor());
}
});
return epollEventLoopGroup;
@@ -172,6 +174,7 @@ public EventLoopGroup kqueueGroup() {
protected void initChannel(final KQueueDomainSocketChannel channel) throws Exception {
channel.pipeline().addLast(new LoggingHandler(getClass()));
channel.pipeline().addLast(new HttpClientCodec());
+ channel.pipeline().addLast(new HttpContentDecompressor());
}
});
@@ -212,6 +215,7 @@ protected void initChannel(final SocketChannel channel) throws Exception {
// channel.pipeline().addLast(new
// HttpProxyHandler(proxyAddress));
channel.pipeline().addLast(new HttpClientCodec());
+ channel.pipeline().addLast(new HttpContentDecompressor());
}
});
diff --git a/src/main/java/com/github/dockerjava/netty/NettyInvocationBuilder.java b/src/main/java/com/github/dockerjava/netty/NettyInvocationBuilder.java
index 952fea3ac..c57f885be 100644
--- a/src/main/java/com/github/dockerjava/netty/NettyInvocationBuilder.java
+++ b/src/main/java/com/github/dockerjava/netty/NettyInvocationBuilder.java
@@ -3,6 +3,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
import com.github.dockerjava.api.async.ResultCallback;
import com.github.dockerjava.api.exception.DockerClientException;
import com.github.dockerjava.api.model.Frame;
@@ -150,7 +151,7 @@ public void get(TypeReference typeReference, ResultCallback resultCall
HttpResponseHandler responseHandler = new HttpResponseHandler(requestProvider, resultCallback);
channel.pipeline().addLast(responseHandler);
- channel.pipeline().addLast(new JsonObjectDecoder());
+ channel.pipeline().addLast(new JsonObjectDecoder(3 * 1024 * 1024));
channel.pipeline().addLast(jsonResponseHandler);
sendRequest(requestProvider, channel);
@@ -299,7 +300,7 @@ public void post(final Object entity, TypeReference typeReference, final
HttpResponseHandler responseHandler = new HttpResponseHandler(requestProvider, resultCallback);
channel.pipeline().addLast(responseHandler);
- channel.pipeline().addLast(new JsonObjectDecoder());
+ channel.pipeline().addLast(new JsonObjectDecoder(3 * 1024 * 1024));
channel.pipeline().addLast(jsonResponseHandler);
sendRequest(requestProvider, channel);
@@ -343,7 +344,9 @@ private HttpRequest prepareEntityRequest(String uri, Object entity, HttpMethod h
byte[] bytes;
try {
- bytes = new ObjectMapper().writeValueAsBytes(entity);
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
+ bytes = objectMapper.writeValueAsBytes(entity);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
@@ -405,7 +408,7 @@ public void post(TypeReference typeReference, ResultCallback resultCal
channel.pipeline().addLast(new ChunkedWriteHandler());
channel.pipeline().addLast(responseHandler);
- channel.pipeline().addLast(new JsonObjectDecoder());
+ channel.pipeline().addLast(new JsonObjectDecoder(3 * 1024 * 1024));
channel.pipeline().addLast(jsonResponseHandler);
postChunkedStreamRequest(requestProvider, channel, body);
diff --git a/src/main/java/org/newsclub/net/unix/AFUNIXSocketImpl.java b/src/main/java/org/newsclub/net/unix/AFUNIXSocketImpl.java
deleted file mode 100644
index 869d987f2..000000000
--- a/src/main/java/org/newsclub/net/unix/AFUNIXSocketImpl.java
+++ /dev/null
@@ -1,415 +0,0 @@
-// Modified version (see https://github.com/docker-java/docker-java/pull/697)
-/**
- * junixsocket
- *
- * Copyright (c) 2009,2014 Christian Kohlschütter
- *
- * The author licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.newsclub.net.unix;
-
-import java.io.FileDescriptor;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.SocketAddress;
-import java.net.SocketException;
-import java.net.SocketImpl;
-import java.net.SocketOptions;
-
-/**
- * The Java-part of the {@link AFUNIXSocket} implementation.
- *
- * @author Christian Kohlschütter
- */
-class AFUNIXSocketImpl extends SocketImpl {
- private static final int SHUT_RD = 0;
- private static final int SHUT_WR = 1;
- private static final int SHUT_RD_WR = 2;
-
- private String socketFile;
- private boolean closed = false;
- private boolean bound = false;
- private boolean connected = false;
-
- private boolean closedInputStream = false;
- private boolean closedOutputStream = false;
-
- private final AFUNIXInputStream in = new AFUNIXInputStream();
- private final AFUNIXOutputStream out = new AFUNIXOutputStream();
-
- AFUNIXSocketImpl() {
- super();
- this.fd = new FileDescriptor();
- }
-
- FileDescriptor getFD() {
- return fd;
- }
-
- @Override
- protected void accept(SocketImpl socket) throws IOException {
- final AFUNIXSocketImpl si = (AFUNIXSocketImpl) socket;
- NativeUnixSocket.accept(socketFile, fd, si.fd);
- si.socketFile = socketFile;
- si.connected = true;
- }
-
- @Override
- protected int available() throws IOException {
- return NativeUnixSocket.available(fd);
- }
-
- protected void bind(SocketAddress addr) throws IOException {
- bind(0, addr);
- }
-
- protected void bind(int backlog, SocketAddress addr) throws IOException {
- if (!(addr instanceof AFUNIXSocketAddress)) {
- throw new SocketException("Cannot bind to this type of address: " + addr.getClass());
- }
- final AFUNIXSocketAddress socketAddress = (AFUNIXSocketAddress) addr;
- socketFile = socketAddress.getSocketFile();
- NativeUnixSocket.bind(socketFile, fd, backlog);
- bound = true;
- this.localport = socketAddress.getPort();
- }
-
- @Override
- @SuppressWarnings("hiding")
- protected void bind(InetAddress host, int port) throws IOException {
- throw new SocketException("Cannot bind to this type of address: " + InetAddress.class);
- }
-
- private void checkClose() throws IOException {
- //if (closedInputStream && closedOutputStream) {
- // close();
- //}
- }
-
- @Override
- protected synchronized void close() throws IOException {
- if (closed) {
- return;
- }
- closed = true;
- if (fd.valid()) {
- NativeUnixSocket.shutdown(fd, SHUT_RD_WR);
- NativeUnixSocket.close(fd);
- }
- if (bound) {
- NativeUnixSocket.unlink(socketFile);
- }
- connected = false;
- }
-
- @Override
- @SuppressWarnings("hiding")
- protected void connect(String host, int port) throws IOException {
- throw new SocketException("Cannot bind to this type of address: " + InetAddress.class);
- }
-
- @Override
- @SuppressWarnings("hiding")
- protected void connect(InetAddress address, int port) throws IOException {
- throw new SocketException("Cannot bind to this type of address: " + InetAddress.class);
- }
-
- @Override
- protected void connect(SocketAddress addr, int timeout) throws IOException {
- if (!(addr instanceof AFUNIXSocketAddress)) {
- throw new SocketException("Cannot bind to this type of address: " + addr.getClass());
- }
- final AFUNIXSocketAddress socketAddress = (AFUNIXSocketAddress) addr;
- socketFile = socketAddress.getSocketFile();
- NativeUnixSocket.connect(socketFile, fd);
- this.address = socketAddress.getAddress();
- this.port = socketAddress.getPort();
- this.localport = 0;
- this.connected = true;
- }
-
- @Override
- protected void create(boolean stream) throws IOException {
- }
-
- @Override
- protected InputStream getInputStream() throws IOException {
- if (!connected && !bound) {
- throw new IOException("Not connected/not bound");
- }
- return in;
- }
-
- @Override
- protected OutputStream getOutputStream() throws IOException {
- if (!connected && !bound) {
- throw new IOException("Not connected/not bound");
- }
- return out;
- }
-
- @Override
- protected void listen(int backlog) throws IOException {
- NativeUnixSocket.listen(fd, backlog);
- }
-
- @Override
- protected void sendUrgentData(int data) throws IOException {
- NativeUnixSocket.write(fd, new byte[] {(byte) (data & 0xFF)}, 0, 1);
- }
-
- private final class AFUNIXInputStream extends InputStream {
- private boolean streamClosed = false;
-
- @Override
- public int read(byte[] buf, int off, int len) throws IOException {
- if (streamClosed) {
- throw new IOException("This InputStream has already been closed.");
- }
- if (len == 0) {
- return 0;
- }
- if (closed) {
- return -1;
- }
- int maxRead = buf.length - off;
- if (len > maxRead) {
- len = maxRead;
- }
- try {
- return NativeUnixSocket.read(fd, buf, off, len);
- } catch (final IOException e) {
- throw (IOException) new IOException(e.getMessage() + " at "
- + AFUNIXSocketImpl.this.toString()).initCause(e);
- }
- }
-
- @Override
- public int read() throws IOException {
- final byte[] buf1 = new byte[1];
- final int numRead = read(buf1, 0, 1);
- if (numRead <= 0) {
- return -1;
- } else {
- return buf1[0] & 0xFF;
- }
- }
-
- @Override
- public void close() throws IOException {
- if (streamClosed) {
- return;
- }
- streamClosed = true;
- if (fd.valid()) {
- NativeUnixSocket.shutdown(fd, SHUT_RD);
- }
-
- closedInputStream = true;
- checkClose();
- }
-
- @Override
- public int available() throws IOException {
- final int av = NativeUnixSocket.available(fd);
- return av;
- }
- }
-
- private final class AFUNIXOutputStream extends OutputStream {
- private boolean streamClosed = false;
-
- @Override
- public void write(int oneByte) throws IOException {
- final byte[] buf1 = new byte[] {(byte) oneByte};
- write(buf1, 0, 1);
- }
-
- @Override
- public void write(byte[] buf, int off, int len) throws IOException {
- if (streamClosed) {
- throw new AFUNIXSocketException("This OutputStream has already been closed.");
- }
- if (len > buf.length - off) {
- throw new IndexOutOfBoundsException();
- }
- try {
- while (len > 0 && !Thread.interrupted()) {
- final int written = NativeUnixSocket.write(fd, buf, off, len);
- if (written == -1) {
- throw new IOException("Unspecific error while writing");
- }
- len -= written;
- off += written;
- }
- } catch (final IOException e) {
- throw (IOException) new IOException(e.getMessage() + " at "
- + AFUNIXSocketImpl.this.toString()).initCause(e);
- }
- }
-
- @Override
- public void close() throws IOException {
- if (streamClosed) {
- return;
- }
- streamClosed = true;
- if (fd.valid()) {
- NativeUnixSocket.shutdown(fd, SHUT_WR);
- }
- closedOutputStream = true;
- checkClose();
- }
- }
-
- @Override
- public String toString() {
- return super.toString() + "[fd=" + fd + "; file=" + this.socketFile + "; connected="
- + connected + "; bound=" + bound + "]";
- }
-
- private static int expectInteger(Object value) throws SocketException {
- try {
- return (Integer) value;
- } catch (final ClassCastException e) {
- throw new AFUNIXSocketException("Unsupported value: " + value, e);
- } catch (final NullPointerException e) {
- throw new AFUNIXSocketException("Value must not be null", e);
- }
- }
-
- private static int expectBoolean(Object value) throws SocketException {
- try {
- return ((Boolean) value).booleanValue() ? 1 : 0;
- } catch (final ClassCastException e) {
- throw new AFUNIXSocketException("Unsupported value: " + value, e);
- } catch (final NullPointerException e) {
- throw new AFUNIXSocketException("Value must not be null", e);
- }
- }
-
- @Override
- public Object getOption(int optID) throws SocketException {
- try {
- switch (optID) {
- case SocketOptions.SO_KEEPALIVE:
- case SocketOptions.TCP_NODELAY:
- return NativeUnixSocket.getSocketOptionInt(fd, optID) != 0 ? true : false;
- case SocketOptions.SO_LINGER:
- case SocketOptions.SO_TIMEOUT:
- case SocketOptions.SO_RCVBUF:
- case SocketOptions.SO_SNDBUF:
- return NativeUnixSocket.getSocketOptionInt(fd, optID);
- default:
- throw new AFUNIXSocketException("Unsupported option: " + optID);
- }
- } catch (final AFUNIXSocketException e) {
- throw e;
- } catch (final Exception e) {
- throw new AFUNIXSocketException("Error while getting option", e);
- }
- }
-
- @Override
- public void setOption(int optID, Object value) throws SocketException {
- try {
- switch (optID) {
- case SocketOptions.SO_LINGER:
-
- if (value instanceof Boolean) {
- final boolean b = (Boolean) value;
- if (b) {
- throw new SocketException("Only accepting Boolean.FALSE here");
- }
- NativeUnixSocket.setSocketOptionInt(fd, optID, -1);
- return;
- }
- NativeUnixSocket.setSocketOptionInt(fd, optID, expectInteger(value));
- return;
- case SocketOptions.SO_RCVBUF:
- case SocketOptions.SO_SNDBUF:
- case SocketOptions.SO_TIMEOUT:
- NativeUnixSocket.setSocketOptionInt(fd, optID, expectInteger(value));
- return;
- case SocketOptions.SO_KEEPALIVE:
- case SocketOptions.TCP_NODELAY:
- NativeUnixSocket.setSocketOptionInt(fd, optID, expectBoolean(value));
- return;
- default:
- throw new AFUNIXSocketException("Unsupported option: " + optID);
- }
- } catch (final AFUNIXSocketException e) {
- throw e;
- } catch (final Exception e) {
- throw new AFUNIXSocketException("Error while setting option", e);
- }
- }
-
- @Override
- protected void shutdownInput() throws IOException {
- if (!closed && fd.valid()) {
- NativeUnixSocket.shutdown(fd, SHUT_RD);
- }
- }
-
- @Override
- protected void shutdownOutput() throws IOException {
- if (!closed && fd.valid()) {
- NativeUnixSocket.shutdown(fd, SHUT_WR);
- }
- }
-
- /**
- * Changes the behavior to be somewhat lenient with respect to the specification.
- *
- * In particular, we ignore calls to {@link Socket#getTcpNoDelay()} and
- * {@link Socket#setTcpNoDelay(boolean)}.
- */
- static class Lenient extends AFUNIXSocketImpl {
- Lenient() {
- super();
- }
-
- @Override
- public void setOption(int optID, Object value) throws SocketException {
- try {
- super.setOption(optID, value);
- } catch (SocketException e) {
- switch (optID) {
- case SocketOptions.TCP_NODELAY:
- return;
- default:
- throw e;
- }
- }
- }
-
- @Override
- public Object getOption(int optID) throws SocketException {
- try {
- return super.getOption(optID);
- } catch (SocketException e) {
- switch (optID) {
- case SocketOptions.TCP_NODELAY:
- case SocketOptions.SO_KEEPALIVE:
- return false;
- default:
- throw e;
- }
- }
- }
- }
-}
diff --git a/src/test/java/com/github/dockerjava/api/command/InspectContainerResponseTest.java b/src/test/java/com/github/dockerjava/api/command/InspectContainerResponseTest.java
index ce3a6b83e..c8fed9cce 100644
--- a/src/test/java/com/github/dockerjava/api/command/InspectContainerResponseTest.java
+++ b/src/test/java/com/github/dockerjava/api/command/InspectContainerResponseTest.java
@@ -17,11 +17,14 @@
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.dockerjava.api.model.ContainerNetwork;
+import com.github.dockerjava.api.model.Isolation;
import com.github.dockerjava.api.model.Volume;
import com.github.dockerjava.core.RemoteApiVersion;
import org.junit.Test;
import java.io.IOException;
+import java.util.Collections;
import java.util.List;
import static com.github.dockerjava.test.serdes.JSONSamples.testRoundTrip;
@@ -30,6 +33,7 @@
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyString;
+import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertEquals;
@@ -65,7 +69,7 @@ public void roundTrip_full() throws IOException {
public void roundTrip_full_healthcheck() throws IOException {
final ObjectMapper mapper = new ObjectMapper();
- final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(InspectContainerResponse.class);
+ final JavaType type = mapper.getTypeFactory().constructType(InspectContainerResponse.class);
final InspectContainerResponse response = testRoundTrip(RemoteApiVersion.VERSION_1_24,
"/containers/inspect/1.json",
@@ -131,4 +135,57 @@ public void roundTrip_1_26b_full() throws IOException {
public void roundTrip_empty() throws IOException {
testRoundTrip(CommandJSONSamples.inspectContainerResponse_empty, InspectContainerResponse[].class);
}
+
+ @Test
+ public void inspect_windows_container() throws IOException {
+
+ final ObjectMapper mapper = new ObjectMapper();
+ final JavaType type = mapper.getTypeFactory().constructType(InspectContainerResponse.class);
+
+ final InspectContainerResponse response = testRoundTrip(RemoteApiVersion.VERSION_1_38,
+ "/containers/inspect/lcow.json",
+ type
+ );
+
+ assertThat(response, notNullValue());
+
+ assertThat(response.getConfig(), notNullValue());
+ assertThat(response.getConfig().getCmd(), is(new String[]{"cmd"}));
+ assertThat(response.getConfig().getImage(), is("microsoft/nanoserver"));
+
+ assertThat(response.getDriver(), is("windowsfilter"));
+
+ assertThat(response.getGraphDriver(), notNullValue());
+ assertThat(response.getGraphDriver().getName(), is("windowsfilter"));
+ assertThat(response.getGraphDriver().getData(), is(new GraphData().withDir(
+ "C:\\ProgramData\\Docker\\windowsfilter\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556"
+ )));
+
+ assertThat(response.getHostConfig(), notNullValue());
+ assertThat(response.getHostConfig().getIsolation(), is(Isolation.HYPERV));
+
+ assertThat(response.getImageId(), is("sha256:1381511ec0122f197b6abff5bc0692bef19943ddafd6680eff41197afa3a6dda"));
+ assertThat(response.getLogPath(), is(
+ "C:\\ProgramData\\Docker\\containers\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556" +
+ "\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556-json.log"
+ ));
+ assertThat(response.getName(), is("/cranky_clarke"));
+
+ assertThat(response.getNetworkSettings(), notNullValue());
+ assertThat(response.getNetworkSettings().getNetworks(), is(Collections.singletonMap("nat",
+ new ContainerNetwork()
+ .withEndpointId("493b77d6fe7e3b92435b1eb01461fde669781330deb84a9cbada360db8997ebc")
+ .withGateway("172.17.18.1")
+ .withGlobalIPv6Address("")
+ .withGlobalIPv6PrefixLen(0)
+ .withIpv4Address("172.17.18.123")
+ .withIpPrefixLen(16)
+ .withIpV6Gateway("")
+ .withMacAddress("00:aa:ff:cf:dd:09")
+ .withNetworkID("398c0e206dd677ed4a6566f9de458311f5767d8c7a8b963275490ab64c5d10a7")
+ )));
+
+ assertThat(response.getPath(), is("cmd"));
+ assertThat(response.getPlatform(), is("windows"));
+ }
}
diff --git a/src/test/java/com/github/dockerjava/api/command/InspectExecResponseTest.java b/src/test/java/com/github/dockerjava/api/command/InspectExecResponseTest.java
index 7290f121b..9c2641885 100644
--- a/src/test/java/com/github/dockerjava/api/command/InspectExecResponseTest.java
+++ b/src/test/java/com/github/dockerjava/api/command/InspectExecResponseTest.java
@@ -21,7 +21,7 @@ public class InspectExecResponseTest {
@Test
public void test_1_22_SerDer1() throws Exception {
final ObjectMapper mapper = new ObjectMapper();
- final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(InspectExecResponse.class);
+ final JavaType type = mapper.getTypeFactory().constructType(InspectExecResponse.class);
final InspectExecResponse execResponse = testRoundTrip(RemoteApiVersion.VERSION_1_22,
"/exec/ID/1.json",
diff --git a/src/test/java/com/github/dockerjava/api/command/InspectImageResponseTest.java b/src/test/java/com/github/dockerjava/api/command/InspectImageResponseTest.java
index ca17ec58a..2cfde68d7 100644
--- a/src/test/java/com/github/dockerjava/api/command/InspectImageResponseTest.java
+++ b/src/test/java/com/github/dockerjava/api/command/InspectImageResponseTest.java
@@ -9,6 +9,7 @@
import java.util.Collections;
import static com.github.dockerjava.core.RemoteApiVersion.VERSION_1_22;
+import static com.github.dockerjava.core.RemoteApiVersion.VERSION_1_25;
import static com.github.dockerjava.test.serdes.JSONSamples.testRoundTrip;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
@@ -206,4 +207,49 @@ public void testOverlayNetworkRootDir() throws IOException {
assertThat(graphDriver.getName(), is("overlay"));
assertThat(graphDriver.getData(), equalTo(overlayGraphData));
}
+
+ @Test
+ public void inspectWindowsImage() throws IOException {
+ final ObjectMapper mapper = new ObjectMapper();
+ final JavaType type = mapper.getTypeFactory().constructType(InspectImageResponse.class);
+
+ final InspectImageResponse inspectImage = testRoundTrip(VERSION_1_25,
+ "images/windowsImage/doc.json",
+ type
+ );
+
+ assertThat(inspectImage, notNullValue());
+
+ assertThat(inspectImage.getRepoTags(), hasSize(1));
+ assertThat(inspectImage.getRepoTags(), contains(
+ "microsoft/nanoserver:latest"
+ ));
+
+ assertThat(inspectImage.getRepoDigests(), hasSize(1));
+ assertThat(inspectImage.getRepoDigests(), contains("microsoft/nanoserver@" +
+ "sha256:aee7d4330fe3dc5987c808f647441c16ed2fa1c7d9c6ef49d6498e5c9860b50b")
+ );
+
+ assertThat(inspectImage.getConfig(), notNullValue());
+ assertThat(inspectImage.getConfig().getCmd(), is(new String[]{"c:\\windows\\system32\\cmd.exe"}));
+
+ assertThat(inspectImage.getOs(), is("windows"));
+ assertThat(inspectImage.getOsVersion(), is("10.0.14393"));
+ assertThat(inspectImage.getSize(), is(651862727L));
+ assertThat(inspectImage.getVirtualSize(), is(651862727L));
+
+ assertThat(inspectImage.getGraphDriver(), notNullValue());
+ assertThat(inspectImage.getGraphDriver().getName(), is("windowsfilter"));
+ assertThat(inspectImage.getGraphDriver().getData(), notNullValue());
+ assertThat(inspectImage.getGraphDriver().getData().getDir(), is("C:\\control\\windowsfilter\\" +
+ "6fe6a289b98276a6a5ca0345156ca61d7b38f3da6bb49ef95af1d0f1ac37e5bf"
+ ));
+
+ assertThat(inspectImage.getRootFS(), notNullValue());
+ assertThat(inspectImage.getRootFS().getType(), is("layers"));
+ assertThat(inspectImage.getRootFS().getLayers(), hasSize(1));
+ assertThat(inspectImage.getRootFS().getLayers(), contains(
+ "sha256:342d4e407550c52261edd20cd901b5ce438f0b1e940336de3978210612365063"
+ ));
+ }
}
diff --git a/src/test/java/com/github/dockerjava/api/model/AuthConfigTest.java b/src/test/java/com/github/dockerjava/api/model/AuthConfigTest.java
index 351086d19..d470ff1d7 100644
--- a/src/test/java/com/github/dockerjava/api/model/AuthConfigTest.java
+++ b/src/test/java/com/github/dockerjava/api/model/AuthConfigTest.java
@@ -10,6 +10,7 @@
import static com.github.dockerjava.test.serdes.JSONSamples.testRoundTrip;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertEquals;
@@ -24,7 +25,7 @@ public void defaultServerAddress() throws Exception {
@Test
public void serderDocs1() throws IOException {
final ObjectMapper mapper = new ObjectMapper();
- final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(AuthConfig.class);
+ final JavaType type = mapper.getTypeFactory().constructType(AuthConfig.class);
final AuthConfig authConfig = testRoundTrip(RemoteApiVersion.VERSION_1_22,
"/other/AuthConfig/docs1.json",
@@ -46,7 +47,7 @@ public void serderDocs1() throws IOException {
@Test
public void serderDocs2() throws IOException {
final ObjectMapper mapper = new ObjectMapper();
- final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(AuthConfig.class);
+ final JavaType type = mapper.getTypeFactory().constructType(AuthConfig.class);
final AuthConfig authConfig = testRoundTrip(RemoteApiVersion.VERSION_1_22,
"/other/AuthConfig/docs2.json",
@@ -61,4 +62,35 @@ public void serderDocs2() throws IOException {
assertThat(authConfig1, equalTo(authConfig));
}
+
+ @Test
+ public void compatibleWithIdentitytoken() throws IOException {
+ final ObjectMapper mapper = new ObjectMapper();
+ final JavaType type = mapper.getTypeFactory().constructType(AuthConfig.class);
+ final AuthConfig authConfig = testRoundTrip(RemoteApiVersion.VERSION_1_23,
+ "/other/AuthConfig/docs1.json",
+ type
+ );
+ String auth = "YWRtaW46";
+ String identitytoken = "1cba468e-8cbe-4c55-9098-2c2ed769e885";
+ assertThat(authConfig, notNullValue());
+ assertThat(authConfig.getAuth(), is(auth));
+ assertThat(authConfig.getIdentitytoken(), is(identitytoken));
+ final AuthConfig authConfig1 = new AuthConfig().withAuth(auth).withIdentityToken(identitytoken);
+ assertThat(authConfig1, equalTo(authConfig));
+ }
+
+ @Test
+ public void shouldNotFailWithStackOrchestratorInConfig() throws IOException {
+ final ObjectMapper mapper = new ObjectMapper();
+ final JavaType type = mapper.getTypeFactory().constructType(AuthConfig.class);
+ final AuthConfig authConfig = testRoundTrip(RemoteApiVersion.VERSION_1_25,
+ "/other/AuthConfig/orchestrators.json",
+ type
+ );
+ assertThat(authConfig, notNullValue());
+ assertThat(authConfig.getAuth(), is(nullValue()));
+ assertThat(authConfig.getStackOrchestrator(), is("kubernetes"));
+ }
+
}
diff --git a/src/test/java/com/github/dockerjava/api/model/EventsTest.java b/src/test/java/com/github/dockerjava/api/model/EventsTest.java
index c517b80a9..05b6a7a1d 100644
--- a/src/test/java/com/github/dockerjava/api/model/EventsTest.java
+++ b/src/test/java/com/github/dockerjava/api/model/EventsTest.java
@@ -24,7 +24,7 @@ public class EventsTest {
@Test
public void serderDocs1() throws IOException {
final ObjectMapper mapper = new ObjectMapper();
- final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(Event.class);
+ final JavaType type = mapper.getTypeFactory().constructType(Event.class);
final Event event = testRoundTrip(RemoteApiVersion.VERSION_1_24,
"/events/docs1.json",
diff --git a/src/test/java/com/github/dockerjava/api/model/InfoTest.java b/src/test/java/com/github/dockerjava/api/model/InfoTest.java
index 372abf52f..6e37636ec 100644
--- a/src/test/java/com/github/dockerjava/api/model/InfoTest.java
+++ b/src/test/java/com/github/dockerjava/api/model/InfoTest.java
@@ -3,10 +3,12 @@
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.dockerjava.api.model.InfoRegistryConfig.IndexConfig;
+import com.github.dockerjava.core.RemoteApiVersion;
import org.hamcrest.CoreMatchers;
import org.junit.Test;
import java.io.IOException;
+import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@@ -327,4 +329,39 @@ public void serder2Json() throws IOException {
assertThat(info, is(withInfo));
}
+
+ @Test
+ public void info_1_38() throws IOException {
+ final ObjectMapper mapper = new ObjectMapper();
+ final JavaType type = mapper.getTypeFactory().constructType(Info.class);
+
+ final Info info = testRoundTrip(RemoteApiVersion.VERSION_1_38,
+ "info/lcow.json",
+ type
+ );
+
+ assertThat(info, notNullValue());
+ assertThat(info.getArchitecture(), is("x86_64"));
+ assertThat(info.getDockerRootDir(), is("C:\\ProgramData\\Docker"));
+ assertThat(info.getDriver(), is("windowsfilter (windows) lcow (linux)"));
+
+ assertThat(info.getDriverStatuses(), equalTo(Arrays.asList(
+ Arrays.asList("Windows", ""),
+ Arrays.asList("LCOW", "")
+ )));
+
+ assertThat(info.getIsolation(), is("hyperv"));
+ assertThat(info.getKernelVersion(), is("10.0 17134 (17134.1.amd64fre.rs4_release.180410-1804)"));
+ assertThat(info.getOsType(), is("windows"));
+ assertThat(info.getOperatingSystem(), is("Windows 10 Pro Version 1803 (OS Build 17134.228)"));
+
+ final Map> plugins = new LinkedHashMap<>();
+ plugins.put("Authorization", null);
+ plugins.put("Log", asList("awslogs", "etwlogs", "fluentd", "gelf", "json-file", "logentries", "splunk", "syslog"));
+ plugins.put("Network", asList("ics", "l2bridge", "l2tunnel", "nat", "null", "overlay", "transparent"));
+ plugins.put("Volume", singletonList("local"));
+ assertThat(info.getPlugins(), equalTo(plugins));
+
+ assertThat(info.getServerVersion(), is("18.06.1-ce"));
+ }
}
diff --git a/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java b/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java
index c0bc01d84..261fe7d1b 100644
--- a/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java
+++ b/src/test/java/com/github/dockerjava/api/model/StatisticsTest.java
@@ -3,6 +3,7 @@
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.dockerjava.core.RemoteApiVersion;
+import org.hamcrest.Matchers;
import org.junit.Test;
import java.io.IOException;
@@ -22,7 +23,7 @@ public class StatisticsTest {
@Test
public void serderJson1() throws IOException {
final ObjectMapper mapper = new ObjectMapper();
- final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(Statistics.class);
+ final JavaType type = mapper.getTypeFactory().constructType(Statistics.class);
final Statistics statistics = testRoundTrip(RemoteApiVersion.VERSION_1_27,
"containers/container/stats/stats1.json",
@@ -82,11 +83,26 @@ public void serderJson1() throws IOException {
assertThat(stats.getWriteback(), is(0L));
assertThat(memoryStats.getLimit(), is(2095874048L));
+ assertThat(memoryStats.getFailcnt(), is(0L));
final BlkioStatsConfig blkioStats = statistics.getBlkioStats();
- assertThat(blkioStats.getIoServiceBytesRecursive().size(), is(2));
- assertThat(blkioStats.getIoServiceBytesRecursive().get(0).getValue(), is(26214L));
- assertThat(blkioStats.getIoServicedRecursive().size(), is(2));
+ assertThat(blkioStats.getIoServiceBytesRecursive(), Matchers.hasSize(5));
+ assertThat(blkioStats.getIoServiceBytesRecursive(), equalTo(Arrays.asList(
+ new BlkioStatEntry().withMajor(259L).withMinor(0L).withOp("Read").withValue(823296L),
+ new BlkioStatEntry().withMajor(259L).withMinor(0L).withOp("Write").withValue(122880L),
+ new BlkioStatEntry().withMajor(259L).withMinor(0L).withOp("Sync").withValue(835584L),
+ new BlkioStatEntry().withMajor(259L).withMinor(0L).withOp("Async").withValue(110592L),
+ new BlkioStatEntry().withMajor(259L).withMinor(0L).withOp("Total").withValue(946176L)
+ )));
+
+ assertThat(blkioStats.getIoServicedRecursive(), Matchers.hasSize(5));
+ assertThat(blkioStats.getIoServicedRecursive(), equalTo(Arrays.asList(
+ new BlkioStatEntry().withMajor(259L).withMinor(0L).withOp("Read").withValue(145L),
+ new BlkioStatEntry().withMajor(259L).withMinor(0L).withOp("Write").withValue(4L),
+ new BlkioStatEntry().withMajor(259L).withMinor(0L).withOp("Sync").withValue(148L),
+ new BlkioStatEntry().withMajor(259L).withMinor(0L).withOp("Async").withValue(1L),
+ new BlkioStatEntry().withMajor(259L).withMinor(0L).withOp("Total").withValue(149L)
+ )));
assertThat(blkioStats.getIoQueueRecursive(), is(empty()));
assertThat(blkioStats.getIoServiceTimeRecursive(), is(empty()));
assertThat(blkioStats.getIoWaitTimeRecursive(), is(empty()));
diff --git a/src/test/java/com/github/dockerjava/api/model/VersionTest.java b/src/test/java/com/github/dockerjava/api/model/VersionTest.java
index a2da244c5..1c3e55c5c 100644
--- a/src/test/java/com/github/dockerjava/api/model/VersionTest.java
+++ b/src/test/java/com/github/dockerjava/api/model/VersionTest.java
@@ -5,9 +5,15 @@
import com.github.dockerjava.core.RemoteApiVersion;
import org.junit.Test;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
import static com.github.dockerjava.test.serdes.JSONSamples.testRoundTrip;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
/**
@@ -18,7 +24,7 @@ public class VersionTest {
@Test
public void testSerDer1() throws Exception {
final ObjectMapper mapper = new ObjectMapper();
- final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(Version.class);
+ final JavaType type = mapper.getTypeFactory().constructType(Version.class);
final Version version = testRoundTrip(RemoteApiVersion.VERSION_1_22,
"/version/1.json",
@@ -37,4 +43,46 @@ public void testSerDer1() throws Exception {
assertThat(version.getBuildTime(), is("2016-02-11T20:39:58.688092588+00:00"));
}
+ @Test
+ public void version_1_38() throws Exception {
+ final ObjectMapper mapper = new ObjectMapper();
+ final JavaType type = mapper.getTypeFactory().constructType(Version.class);
+
+ final Version version = testRoundTrip(RemoteApiVersion.VERSION_1_38,
+ "/version/lcow.json",
+ type
+ );
+
+ assertThat(version, notNullValue());
+ assertThat(version.getApiVersion(), is("1.38"));
+ assertThat(version.getArch(), is("amd64"));
+ assertThat(version.getBuildTime(), is("2018-08-21T17:36:40.000000000+00:00"));
+
+ Map details = new LinkedHashMap<>();
+ details.put("ApiVersion", "1.38");
+ details.put("Arch", "amd64");
+ details.put("BuildTime", "2018-08-21T17:36:40.000000000+00:00");
+ details.put("Experimental", "true");
+ details.put("GitCommit", "e68fc7a");
+ details.put("GoVersion", "go1.10.3");
+ details.put("KernelVersion", "10.0 17134 (17134.1.amd64fre.rs4_release.180410-1804)");
+ details.put("MinAPIVersion", "1.24");
+ details.put("Os", "windows");
+
+ List components = Collections.singletonList(new VersionComponent()
+ .withDetails(details)
+ .withName("Engine")
+ .withVersion("18.06.1-ce")
+ );
+ assertThat(version.getComponents(), equalTo(components));
+
+ assertThat(version.getExperimental(), is(true));
+ assertThat(version.getGitCommit(), is("e68fc7a"));
+ assertThat(version.getGoVersion(), is("go1.10.3"));
+ assertThat(version.getKernelVersion(), is("10.0 17134 (17134.1.amd64fre.rs4_release.180410-1804)"));
+ assertThat(version.getMinAPIVersion(), is("1.24"));
+ assertThat(version.getOperatingSystem(), is("windows"));
+ assertThat(version.getPlatform(), equalTo(new VersionPlatform().withName("")));
+ assertThat(version.getVersion(), is("18.06.1-ce"));
+ }
}
diff --git a/src/test/java/com/github/dockerjava/cmd/BuildImageCmdIT.java b/src/test/java/com/github/dockerjava/cmd/BuildImageCmdIT.java
index 89d9d5b33..aae6380d8 100644
--- a/src/test/java/com/github/dockerjava/cmd/BuildImageCmdIT.java
+++ b/src/test/java/com/github/dockerjava/cmd/BuildImageCmdIT.java
@@ -302,8 +302,7 @@ public void cacheFrom() throws Exception {
assertThat(inspectImageResponse1, not(nullValue()));
File baseDir2 = fileFromBuildTestResource("CacheFrom/test2");
- String cacheImage = String.format("[\"%s\"]", imageId1);
- String imageId2 = dockerRule.getClient().buildImageCmd(baseDir2).withCacheFrom(new HashSet<>(Arrays.asList(cacheImage)))
+ String imageId2 = dockerRule.getClient().buildImageCmd(baseDir2).withCacheFrom(new HashSet<>(Arrays.asList(imageId1)))
.exec(new BuildImageResultCallback())
.awaitImageId();
InspectImageResponse inspectImageResponse2 = dockerRule.getClient().inspectImageCmd(imageId2).exec();
diff --git a/src/test/java/com/github/dockerjava/cmd/CreateContainerCmdIT.java b/src/test/java/com/github/dockerjava/cmd/CreateContainerCmdIT.java
index 070498a4f..570f20f64 100644
--- a/src/test/java/com/github/dockerjava/cmd/CreateContainerCmdIT.java
+++ b/src/test/java/com/github/dockerjava/cmd/CreateContainerCmdIT.java
@@ -48,6 +48,7 @@
import static com.github.dockerjava.api.model.Capability.MKNOD;
import static com.github.dockerjava.api.model.Capability.NET_ADMIN;
+import static com.github.dockerjava.api.model.HostConfig.newHostConfig;
import static com.github.dockerjava.cmd.CmdIT.FactoryType.JERSEY;
import static com.github.dockerjava.core.RemoteApiVersion.VERSION_1_23;
import static com.github.dockerjava.core.RemoteApiVersion.VERSION_1_24;
@@ -70,6 +71,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
@@ -159,7 +161,8 @@ public void createContainerWithVolumesFrom() throws DockerException {
CreateContainerResponse container1 = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
.withCmd("sleep", "9999")
.withName(container1Name)
- .withBinds(bind1, bind2)
+ .withHostConfig(newHostConfig()
+ .withBinds(bind1, bind2))
.exec();
LOG.info("Created container1 {}", container1.toString());
@@ -174,7 +177,8 @@ public void createContainerWithVolumesFrom() throws DockerException {
// create a second container with volumes from first container
CreateContainerResponse container2 = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
.withCmd("sleep", "9999")
- .withVolumesFrom(new VolumesFrom(container1Name))
+ .withHostConfig(newHostConfig()
+ .withVolumesFrom(new VolumesFrom(container1Name)))
.exec();
LOG.info("Created container2 {}", container2.toString());
@@ -284,7 +288,10 @@ public void createContainerWithLink() throws DockerException {
assertThat(inspectContainerResponse1.getState().getRunning(), is(true));
CreateContainerResponse container2 = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE).withName(containerName2)
- .withCmd("env").withLinks(new Link(containerName1, "container1Link")).exec();
+ .withCmd("env")
+ .withHostConfig(newHostConfig()
+ .withLinks(new Link(containerName1, "container1Link")))
+ .exec();
LOG.info("Created container {}", container2.toString());
assertThat(container2.getId(), not(isEmptyString()));
@@ -294,6 +301,26 @@ public void createContainerWithLink() throws DockerException {
"container1Link")}));
}
+ @Test
+ public void createContainerWithMemorySwappiness() throws DockerException {
+ CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
+ .withCmd("sleep", "9999")
+ .withHostConfig(newHostConfig()
+ .withMemorySwappiness(42L))
+ .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(42L, inspectContainerResponse.getHostConfig().getMemorySwappiness());
+ }
+
@Test
public void createContainerWithLinkInCustomNetwork() throws DockerException {
String containerName1 = "containerCustomlink_" + dockerRule.getKind();
@@ -308,7 +335,8 @@ public void createContainerWithLinkInCustomNetwork() throws DockerException {
assertNotNull(createNetworkResponse.getId());
CreateContainerResponse container1 = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
- .withNetworkMode(networkName)
+ .withHostConfig(newHostConfig()
+ .withNetworkMode(networkName))
.withCmd("sleep", "9999")
.withName(containerName1)
.exec();
@@ -323,10 +351,11 @@ public void createContainerWithLinkInCustomNetwork() throws DockerException {
assertThat(inspectContainerResponse1.getState().getRunning(), is(true));
CreateContainerResponse container2 = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
- .withNetworkMode(networkName)
+ .withHostConfig(newHostConfig()
+ .withLinks(new Link(containerName1, containerName1 + "Link"))
+ .withNetworkMode(networkName))
.withName(containerName2)
.withCmd("env")
- .withLinks(new Link(containerName1, containerName1 + "Link"))
.exec();
LOG.info("Created container {}", container2.toString());
@@ -357,10 +386,11 @@ public void createContainerWithCustomIp() throws DockerException {
assertNotNull(createNetworkResponse.getId());
CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
- .withNetworkMode(networkName)
+ .withHostConfig(newHostConfig()
+ .withNetworkMode(networkName))
.withCmd("sleep", "9999")
.withName(containerName1)
- .withIpv4Address(subnetPrefix +".100")
+ .withIpv4Address(subnetPrefix + ".100")
.exec();
assertThat(container.getId(), not(isEmptyString()));
@@ -390,7 +420,8 @@ public void createContainerWithAlias() throws DockerException {
assertNotNull(createNetworkResponse.getId());
CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
- .withNetworkMode(networkName)
+ .withHostConfig(newHostConfig()
+ .withNetworkMode(networkName))
.withCmd("sleep", "9999")
.withName(containerName1)
.withAliases("server" + dockerRule.getKind())
@@ -410,8 +441,11 @@ public void createContainerWithAlias() throws DockerException {
@Test
public void createContainerWithCapAddAndCapDrop() throws DockerException {
- CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE).withCapAdd(NET_ADMIN)
- .withCapDrop(MKNOD).exec();
+ CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
+ .withHostConfig(newHostConfig()
+ .withCapAdd(NET_ADMIN)
+ .withCapDrop(MKNOD))
+ .exec();
LOG.info("Created container {}", container.toString());
@@ -431,7 +465,9 @@ public void createContainerWithDns() throws DockerException {
String anotherDnsServer = "8.8.4.4";
CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE).withCmd("true")
- .withDns(aDnsServer, anotherDnsServer).exec();
+ .withHostConfig(newHostConfig()
+ .withDns(aDnsServer, anotherDnsServer))
+ .exec();
LOG.info("Created container {}", container.toString());
@@ -467,7 +503,8 @@ public void createContainerWithExtraHosts() throws DockerException {
CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
.withName("containerextrahosts" + dockerRule.getKind())
- .withExtraHosts(extraHosts).exec();
+ .withHostConfig(newHostConfig()
+ .withExtraHosts(extraHosts)).exec();
LOG.info("Created container {}", container.toString());
@@ -483,7 +520,9 @@ public void createContainerWithExtraHosts() throws DockerException {
public void createContainerWithDevices() throws DockerException {
CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE).withCmd("sleep", "9999")
- .withDevices(new Device("rwm", "/dev/nulo", "/dev/zero")).exec();
+ .withHostConfig(newHostConfig()
+ .withDevices(new Device("rwm", "/dev/nulo", "/dev/zero")))
+ .exec();
LOG.info("Created container {}", container.toString());
@@ -497,7 +536,7 @@ public void createContainerWithDevices() throws DockerException {
@Test
public void createContainerWithPortBindings() throws DockerException {
- int baseport = getFactoryType() == FactoryType.JERSEY? 11000: 12000;
+ int baseport = getFactoryType() == FactoryType.JERSEY ? 11000 : 12000;
ExposedPort tcp22 = ExposedPort.tcp(22);
ExposedPort tcp23 = ExposedPort.tcp(23);
@@ -508,7 +547,10 @@ public void createContainerWithPortBindings() throws DockerException {
portBindings.bind(tcp23, Binding.bindPort(baseport + 24));
CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE).withCmd("true")
- .withExposedPorts(tcp22, tcp23).withPortBindings(portBindings).exec();
+ .withExposedPorts(tcp22, tcp23)
+ .withHostConfig(newHostConfig()
+ .withPortBindings(portBindings))
+ .exec();
LOG.info("Created container {}", container.toString());
@@ -561,7 +603,9 @@ public void createContainerWithLinking() throws DockerException {
CreateContainerResponse container2 = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE).withCmd("sleep", "9999")
.withName(containerName2)
- .withLinks(new Link(containerName1, containerName1 + "Link")).exec();
+ .withHostConfig(newHostConfig()
+ .withLinks(new Link(containerName1, containerName1 + "Link")))
+ .exec();
LOG.info("Created container2 {}", container2.toString());
assertThat(container2.getId(), not(isEmptyString()));
@@ -588,7 +632,7 @@ public void createContainerWithRestartPolicy() throws DockerException {
RestartPolicy restartPolicy = RestartPolicy.onFailureRestart(5);
CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE).withCmd("sleep", "9999")
- .withRestartPolicy(restartPolicy).exec();
+ .withHostConfig(newHostConfig().withRestartPolicy(restartPolicy)).exec();
LOG.info("Created container {}", container.toString());
@@ -603,7 +647,7 @@ public void createContainerWithRestartPolicy() throws DockerException {
public void createContainerWithPidMode() throws DockerException {
CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE).withCmd("true")
- .withPidMode("host").exec();
+ .withHostConfig(newHostConfig().withPidMode("host")).exec();
LOG.info("Created container {}", container.toString());
@@ -624,7 +668,9 @@ public void createContainerWithPidMode() throws DockerException {
public void createContainerWithNetworkMode() throws DockerException {
CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE).withCmd("true")
- .withNetworkMode("host").exec();
+ .withHostConfig(newHostConfig()
+ .withNetworkMode("host"))
+ .exec();
LOG.info("Created container {}", container.toString());
@@ -657,7 +703,9 @@ public void createContainerWithULimits() throws DockerException {
CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
.withName(containerName)
- .withUlimits(ulimits).exec();
+ .withHostConfig(newHostConfig()
+ .withUlimits(ulimits))
+ .exec();
LOG.info("Created container {}", container.toString());
@@ -700,7 +748,10 @@ public void createContainerWithLabels() throws DockerException {
public void createContainerWithLogConfig() throws DockerException {
LogConfig logConfig = new LogConfig(LogConfig.LoggingType.NONE, null);
- CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE).withLogConfig(logConfig).exec();
+ CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
+ .withHostConfig(newHostConfig()
+ .withLogConfig(logConfig))
+ .exec();
LOG.info("Created container {}", container.toString());
@@ -769,7 +820,9 @@ public void onNext(Frame item) {
@Test
public void createContainerWithCgroupParent() throws DockerException {
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox")
- .withCgroupParent("/parent").exec();
+ .withHostConfig(newHostConfig()
+ .withCgroupParent("/parent"))
+ .exec();
LOG.info("Created container {}", container.toString());
diff --git a/src/test/java/com/github/dockerjava/cmd/DisconnectFromNetworkCmdIT.java b/src/test/java/com/github/dockerjava/cmd/DisconnectFromNetworkCmdIT.java
index 51faa2ea8..3c9451545 100644
--- a/src/test/java/com/github/dockerjava/cmd/DisconnectFromNetworkCmdIT.java
+++ b/src/test/java/com/github/dockerjava/cmd/DisconnectFromNetworkCmdIT.java
@@ -5,6 +5,7 @@
import com.github.dockerjava.api.model.Network;
import org.junit.Test;
+import static com.github.dockerjava.api.model.HostConfig.newHostConfig;
import static com.github.dockerjava.junit.DockerAssume.assumeNotSwarm;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -40,7 +41,8 @@ public void forceDisconnectFromNetwork() throws InterruptedException {
CreateNetworkResponse network = dockerRule.getClient().createNetworkCmd().withName("testNetwork2" + dockerRule.getKind()).exec();
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox")
- .withNetworkMode("testNetwork2" + dockerRule.getKind())
+ .withHostConfig(newHostConfig()
+ .withNetworkMode("testNetwork2" + dockerRule.getKind()))
.withCmd("sleep", "9999")
.exec();
diff --git a/src/test/java/com/github/dockerjava/cmd/ListContainersCmdIT.java b/src/test/java/com/github/dockerjava/cmd/ListContainersCmdIT.java
index b5210c171..50ba4ca40 100644
--- a/src/test/java/com/github/dockerjava/cmd/ListContainersCmdIT.java
+++ b/src/test/java/com/github/dockerjava/cmd/ListContainersCmdIT.java
@@ -21,6 +21,7 @@
import java.util.UUID;
import static ch.lambdaj.Lambda.filter;
+import static com.github.dockerjava.api.model.HostConfig.newHostConfig;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -257,7 +258,8 @@ public void testVolumeFilter() throws Exception {
id = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
.withLabels(testLabel)
- .withBinds(new Bind("TestFilterVolume", new Volume("/test")))
+ .withHostConfig(newHostConfig()
+ .withBinds(new Bind("TestFilterVolume", new Volume("/test"))))
.exec()
.getId();
@@ -285,7 +287,8 @@ public void testNetworkFilter() throws Exception {
id = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
.withLabels(testLabel)
- .withNetworkMode("TestFilterNetwork")
+ .withHostConfig(newHostConfig()
+ .withNetworkMode("TestFilterNetwork"))
.exec()
.getId();
diff --git a/src/test/java/com/github/dockerjava/cmd/SaveImageCmdIT.java b/src/test/java/com/github/dockerjava/cmd/SaveImageCmdIT.java
index 81abfcd9a..a9ba8ac25 100644
--- a/src/test/java/com/github/dockerjava/cmd/SaveImageCmdIT.java
+++ b/src/test/java/com/github/dockerjava/cmd/SaveImageCmdIT.java
@@ -19,6 +19,10 @@ public void saveImage() throws Exception {
InputStream image = IOUtils.toBufferedInputStream(dockerRule.getClient().saveImageCmd("busybox").exec());
assertThat(image.available(), greaterThan(0));
+ InputStream image2 = IOUtils.toBufferedInputStream(dockerRule.getClient().saveImageCmd("busybox").withTag("latest").exec());
+ assertThat(image2.available(), greaterThan(0));
+
+
}
}
diff --git a/src/test/java/com/github/dockerjava/cmd/StartContainerCmdIT.java b/src/test/java/com/github/dockerjava/cmd/StartContainerCmdIT.java
index f55e43247..5fde7bc03 100644
--- a/src/test/java/com/github/dockerjava/cmd/StartContainerCmdIT.java
+++ b/src/test/java/com/github/dockerjava/cmd/StartContainerCmdIT.java
@@ -29,6 +29,7 @@
import static com.github.dockerjava.api.model.AccessMode.ro;
import static com.github.dockerjava.api.model.Capability.MKNOD;
import static com.github.dockerjava.api.model.Capability.NET_ADMIN;
+import static com.github.dockerjava.api.model.HostConfig.newHostConfig;
import static com.github.dockerjava.junit.DockerMatchers.mountedVolumes;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
@@ -54,7 +55,9 @@ public void startContainerWithVolumes() throws DockerException {
Volume volume2 = new Volume("/opt/webapp2");
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withVolumes(volume1, volume2)
- .withCmd("true").withBinds(new Bind("/src/webapp1", volume1, ro), new Bind("/src/webapp2", volume2))
+ .withCmd("true")
+ .withHostConfig(newHostConfig()
+ .withBinds(new Bind("/src/webapp1", volume1, ro), new Bind("/src/webapp2", volume2)))
.exec();
LOG.info("Created container {}", container.toString());
@@ -95,7 +98,9 @@ public void startContainerWithVolumesFrom() throws DockerException {
CreateContainerResponse container1 = dockerRule.getClient().createContainerCmd("busybox").withCmd("sleep", "9999")
.withName(container1Name)
- .withBinds(new Bind("/src/webapp1", volume1), new Bind("/src/webapp2", volume2)).exec();
+ .withHostConfig(newHostConfig()
+ .withBinds(new Bind("/src/webapp1", volume1), new Bind("/src/webapp2", volume2)))
+ .exec();
LOG.info("Created container1 {}", container1.toString());
dockerRule.getClient().startContainerCmd(container1.getId()).exec();
@@ -107,7 +112,9 @@ public void startContainerWithVolumesFrom() throws DockerException {
assertThat(inspectContainerResponse1, mountedVolumes(containsInAnyOrder(volume1, volume2)));
CreateContainerResponse container2 = dockerRule.getClient().createContainerCmd("busybox").withCmd("sleep", "9999")
- .withVolumesFrom(new VolumesFrom(container1Name)).exec();
+ .withHostConfig(newHostConfig()
+ .withVolumesFrom(new VolumesFrom(container1Name)))
+ .exec();
LOG.info("Created container2 {}", container2.toString());
dockerRule.getClient().startContainerCmd(container2.getId()).exec();
@@ -126,7 +133,9 @@ public void startContainerWithDns() throws DockerException {
String anotherDnsServer = "8.8.4.4";
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("true")
- .withDns(aDnsServer, anotherDnsServer).exec();
+ .withHostConfig(newHostConfig()
+ .withDns(aDnsServer, anotherDnsServer))
+ .exec();
LOG.info("Created container {}", container.toString());
@@ -146,7 +155,9 @@ public void startContainerWithDnsSearch() throws DockerException {
String dnsSearch = "example.com";
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("true")
- .withDnsSearch(dnsSearch).exec();
+ .withHostConfig(newHostConfig()
+ .withDnsSearch(dnsSearch))
+ .exec();
LOG.info("Created container {}", container.toString());
@@ -163,7 +174,7 @@ public void startContainerWithDnsSearch() throws DockerException {
@Test
public void startContainerWithPortBindings() throws DockerException {
- int baseport = getFactoryType() == FactoryType.JERSEY? 13000: 14000;
+ int baseport = getFactoryType() == FactoryType.JERSEY ? 13000 : 14000;
ExposedPort tcp22 = ExposedPort.tcp(22);
ExposedPort tcp23 = ExposedPort.tcp(23);
@@ -174,7 +185,9 @@ public void startContainerWithPortBindings() throws DockerException {
portBindings.bind(tcp23, Binding.bindPort(baseport + 24));
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("true")
- .withExposedPorts(tcp22, tcp23).withPortBindings(portBindings).exec();
+ .withExposedPorts(tcp22, tcp23)
+ .withHostConfig(newHostConfig()
+ .withPortBindings(portBindings)).exec();
LOG.info("Created container {}", container.toString());
@@ -210,7 +223,10 @@ public void startContainerWithRandomPortBindings() throws DockerException {
portBindings.bind(tcp23, Binding.empty());
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("sleep", "9999")
- .withExposedPorts(tcp22, tcp23).withPortBindings(portBindings).withPublishAllPorts(true).exec();
+ .withExposedPorts(tcp22, tcp23).withHostConfig(newHostConfig()
+ .withPortBindings(portBindings)
+ .withPublishAllPorts(true))
+ .exec();
LOG.info("Created container {}", container.toString());
@@ -241,7 +257,9 @@ public void startContainerWithConflictingPortBindings() throws DockerException {
portBindings.bind(tcp23, Binding.bindPort(11022));
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("true")
- .withExposedPorts(tcp22, tcp23).withPortBindings(portBindings).exec();
+ .withExposedPorts(tcp22, tcp23).withHostConfig(newHostConfig()
+ .withPortBindings(portBindings))
+ .exec();
LOG.info("Created container {}", container.toString());
@@ -284,7 +302,9 @@ public void startContainerWithLinkingDeprecated() throws DockerException {
}
CreateContainerResponse container2 = dockerRule.getClient().createContainerCmd("busybox").withCmd("sleep", "9999")
- .withName(container2Name).withLinks(new Link(container1Name, container1Name + "Link")).exec();
+ .withName(container2Name).withHostConfig(newHostConfig()
+ .withLinks(new Link(container1Name, container1Name + "Link")))
+ .exec();
LOG.info("Created container2 {}", container2.toString());
assertThat(container2.getId(), not(isEmptyString()));
@@ -299,7 +319,7 @@ public void startContainerWithLinkingDeprecated() throws DockerException {
assertThat(inspectContainerResponse2.getId(), not(isEmptyString()));
assertThat(inspectContainerResponse2.getHostConfig(), is(notNullValue()));
assertThat(inspectContainerResponse2.getHostConfig().getLinks(), is(notNullValue()));
- assertThat(inspectContainerResponse2.getHostConfig().getLinks(), equalTo(new Link[] {new Link(container1Name,
+ assertThat(inspectContainerResponse2.getHostConfig().getLinks(), equalTo(new Link[]{new Link(container1Name,
container1Name + "Link")}));
assertThat(inspectContainerResponse2.getId(), startsWith(container2.getId()));
assertThat(inspectContainerResponse2.getName(), equalTo("/" + container2Name));
@@ -343,7 +363,9 @@ public void startContainerWithLinking() throws DockerException {
}
CreateContainerResponse container2 = dockerRule.getClient().createContainerCmd("busybox").withCmd("sleep", "9999")
- .withName(container2Name).withLinks(new Link(container1Name, container1Name + "Link")).exec();
+ .withName(container2Name).withHostConfig(newHostConfig()
+ .withLinks(new Link(container1Name, container1Name + "Link")))
+ .exec();
LOG.info("Created container2 {}", container2.toString());
assertThat(container2.getId(), not(isEmptyString()));
@@ -358,7 +380,7 @@ public void startContainerWithLinking() throws DockerException {
assertThat(inspectContainerResponse2.getId(), not(isEmptyString()));
assertThat(inspectContainerResponse2.getHostConfig(), is(notNullValue()));
assertThat(inspectContainerResponse2.getHostConfig().getLinks(), is(notNullValue()));
- assertThat(inspectContainerResponse2.getHostConfig().getLinks(), equalTo(new Link[] {new Link(container1Name,
+ assertThat(inspectContainerResponse2.getHostConfig().getLinks(), equalTo(new Link[]{new Link(container1Name,
container1Name + "Link")}));
assertThat(inspectContainerResponse2.getId(), startsWith(container2.getId()));
assertThat(inspectContainerResponse2.getName(), equalTo("/" + container2Name));
@@ -371,7 +393,7 @@ public void startContainerWithLinking() throws DockerException {
@Test
public void startContainer() throws DockerException {
- CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd(new String[] {"top"})
+ CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd(new String[]{"top"})
.exec();
LOG.info("Created container {}", container.toString());
@@ -400,7 +422,7 @@ public void startContainer() throws DockerException {
@Test(expected = NotFoundException.class)
public void testStartNonExistingContainer() throws DockerException {
- dockerRule.getClient().startContainerCmd("non-existing").exec();
+ dockerRule.getClient().startContainerCmd("non-existing").exec();
}
/**
@@ -413,7 +435,9 @@ public void testStartNonExistingContainer() throws DockerException {
public void startContainerWithNetworkMode() throws DockerException {
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("true")
- .withNetworkMode("host").exec();
+ .withHostConfig(newHostConfig()
+ .withNetworkMode("host"))
+ .exec();
LOG.info("Created container {}", container.toString());
@@ -431,8 +455,12 @@ public void startContainerWithNetworkMode() throws DockerException {
@Test
public void startContainerWithCapAddAndCapDrop() throws DockerException {
- CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("sleep", "9999")
- .withCapAdd(NET_ADMIN).withCapDrop(MKNOD).exec();
+ CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox")
+ .withCmd("sleep", "9999")
+ .withHostConfig(newHostConfig()
+ .withCapAdd(NET_ADMIN)
+ .withCapDrop(MKNOD))
+ .exec();
LOG.info("Created container {}", container.toString());
@@ -452,8 +480,11 @@ public void startContainerWithCapAddAndCapDrop() throws DockerException {
@Test
public void startContainerWithDevices() throws DockerException {
- CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("sleep", "9999")
- .withDevices(new Device("rwm", "/dev/nulo", "/dev/zero")).exec();
+ CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox")
+ .withCmd("sleep", "9999")
+ .withHostConfig(newHostConfig()
+ .withDevices(new Device("rwm", "/dev/nulo", "/dev/zero")))
+ .exec();
LOG.info("Created container {}", container.toString());
@@ -473,7 +504,9 @@ public void startContainerWithDevices() throws DockerException {
public void startContainerWithExtraHosts() throws DockerException {
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("sleep", "9999")
- .withExtraHosts("dockerhost:127.0.0.1").exec();
+ .withHostConfig(newHostConfig()
+ .withExtraHosts("dockerhost:127.0.0.1"))
+ .exec();
LOG.info("Created container {}", container.toString());
@@ -494,8 +527,11 @@ public void startContainerWithRestartPolicy() throws DockerException {
RestartPolicy restartPolicy = RestartPolicy.onFailureRestart(5);
- CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("sleep", "9999")
- .withRestartPolicy(restartPolicy).exec();
+ CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox")
+ .withCmd("sleep", "9999")
+ .withHostConfig(newHostConfig()
+ .withRestartPolicy(restartPolicy))
+ .exec();
LOG.info("Created container {}", container.toString());
@@ -516,7 +552,9 @@ public void existingHostConfigIsPreservedByBlankStartCmd() throws DockerExceptio
String dnsServer = "8.8.8.8";
// prepare a container with custom DNS
- CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withDns(dnsServer)
+ CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox")
+ .withHostConfig(newHostConfig()
+ .withDns(dnsServer))
.withCmd("true").exec();
LOG.info("Created container {}", container.toString());
diff --git a/src/test/java/com/github/dockerjava/cmd/UpdateContainerCmdIT.java b/src/test/java/com/github/dockerjava/cmd/UpdateContainerCmdIT.java
index d63f6aaa2..51d967db5 100644
--- a/src/test/java/com/github/dockerjava/cmd/UpdateContainerCmdIT.java
+++ b/src/test/java/com/github/dockerjava/cmd/UpdateContainerCmdIT.java
@@ -71,8 +71,8 @@ public void updateContainer() throws DockerException, IOException {
// assertThat(afterHostConfig.getBlkioWeight(), is(300));
assertThat(afterHostConfig.getCpuShares(), is(512));
- assertThat(afterHostConfig.getCpuPeriod(), is(100000));
- assertThat(afterHostConfig.getCpuQuota(), is(50000));
+ assertThat(afterHostConfig.getCpuPeriod(), is(100000L));
+ assertThat(afterHostConfig.getCpuQuota(), is(50000L));
assertThat(afterHostConfig.getCpusetMems(), is("0"));
// assertThat(afterHostConfig.getMemoryReservation(), is(209715200L));
@@ -84,7 +84,7 @@ public void updateContainer() throws DockerException, IOException {
@Test
public void serDerDocs1() throws IOException {
final ObjectMapper mapper = new ObjectMapper();
- final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(UpdateContainerCmdImpl.class);
+ final JavaType type = mapper.getTypeFactory().constructType(UpdateContainerCmdImpl.class);
final UpdateContainerCmdImpl upd = testRoundTrip(VERSION_1_22,
"/containers/container/update/docs.json",
diff --git a/src/test/java/com/github/dockerjava/cmd/swarm/SwarmCmdIT.java b/src/test/java/com/github/dockerjava/cmd/swarm/SwarmCmdIT.java
index 112a8e689..686c24794 100644
--- a/src/test/java/com/github/dockerjava/cmd/swarm/SwarmCmdIT.java
+++ b/src/test/java/com/github/dockerjava/cmd/swarm/SwarmCmdIT.java
@@ -19,9 +19,9 @@
import com.github.dockerjava.netty.NettyDockerCmdExecFactory;
import org.junit.After;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.experimental.categories.Category;
+import static com.github.dockerjava.api.model.HostConfig.newHostConfig;
import static com.github.dockerjava.core.RemoteApiVersion.VERSION_1_24;
import static com.github.dockerjava.junit.DockerMatchers.isGreaterOrEqual;
import static org.junit.Assume.assumeThat;
@@ -102,14 +102,17 @@ protected DockerClient startDockerInDocker() {
int port = PORT_START + (numberOfDockersInDocker - 1);
CreateContainerResponse response = dockerRule.getClient()
.createContainerCmd(DOCKER_IN_DOCKER_IMAGE_REPOSITORY + ":" + DOCKER_IN_DOCKER_IMAGE_TAG)
- .withPrivileged(true)
+ .withHostConfig(newHostConfig()
+ .withNetworkMode(NETWORK_NAME)
+ .withPortBindings(new PortBinding(
+ Ports.Binding.bindIpAndPort("127.0.0.1", port),
+ ExposedPort.tcp(2375)))
+ .withPrivileged(true))
.withName(name)
- .withNetworkMode(NETWORK_NAME)
.withAliases(name)
- .withPortBindings(new PortBinding(
- Ports.Binding.bindIpAndPort("127.0.0.1", port),
- ExposedPort.tcp(2375)))
+
.exec();
+
dockerRule.getClient().startContainerCmd(response.getId()).exec();
return initializeDockerClient(port);
diff --git a/src/test/java/com/github/dockerjava/core/DockerConfigFileTest.java b/src/test/java/com/github/dockerjava/core/DockerConfigFileTest.java
index 7f121c69a..b7edb3001 100644
--- a/src/test/java/com/github/dockerjava/core/DockerConfigFileTest.java
+++ b/src/test/java/com/github/dockerjava/core/DockerConfigFileTest.java
@@ -156,7 +156,7 @@ public void nonExistent() throws IOException {
}
private DockerConfigFile runTest(String testFileName) throws IOException {
- return DockerConfigFile.loadConfig(new File(FILESROOT, testFileName));
+ return DockerConfigFile.loadConfig(new File(FILESROOT, testFileName).getAbsolutePath());
}
}
diff --git a/src/test/java/com/github/dockerjava/core/TestDockerCmdExecFactory.java b/src/test/java/com/github/dockerjava/core/TestDockerCmdExecFactory.java
index e2986ef69..a3c96e54d 100644
--- a/src/test/java/com/github/dockerjava/core/TestDockerCmdExecFactory.java
+++ b/src/test/java/com/github/dockerjava/core/TestDockerCmdExecFactory.java
@@ -49,6 +49,7 @@
import com.github.dockerjava.api.command.LogSwarmObjectCmd;
import com.github.dockerjava.api.command.PauseContainerCmd;
import com.github.dockerjava.api.command.PingCmd;
+import com.github.dockerjava.api.command.PruneCmd;
import com.github.dockerjava.api.command.PullImageCmd;
import com.github.dockerjava.api.command.PushImageCmd;
import com.github.dockerjava.api.command.RemoveContainerCmd;
@@ -526,6 +527,11 @@ public ListTasksCmd.Exec listTasksCmdExec() {
return delegate.listTasksCmdExec();
}
+ @Override
+ public PruneCmd.Exec pruneCmdExec() {
+ return delegate.pruneCmdExec();
+ }
+
public List getContainerNames() {
return new ArrayList(containerNames);
}
diff --git a/src/test/java/com/github/dockerjava/core/command/DockerfileFixture.java b/src/test/java/com/github/dockerjava/core/command/DockerfileFixture.java
index 874684e3e..b17947c30 100644
--- a/src/test/java/com/github/dockerjava/core/command/DockerfileFixture.java
+++ b/src/test/java/com/github/dockerjava/core/command/DockerfileFixture.java
@@ -4,6 +4,7 @@
import com.github.dockerjava.api.exception.InternalServerErrorException;
import com.github.dockerjava.api.exception.NotFoundException;
import com.github.dockerjava.api.model.Image;
+import com.github.dockerjava.core.command.BuildImageResultCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/test/java/com/github/dockerjava/core/dockerfile/DockerfileAddMultipleFilesTest.java b/src/test/java/com/github/dockerjava/core/dockerfile/DockerfileAddMultipleFilesTest.java
index ee1f072df..a10990d96 100644
--- a/src/test/java/com/github/dockerjava/core/dockerfile/DockerfileAddMultipleFilesTest.java
+++ b/src/test/java/com/github/dockerjava/core/dockerfile/DockerfileAddMultipleFilesTest.java
@@ -24,6 +24,17 @@ public String apply(File file) {
}
};
+ @Test
+ public void ignoreAllBut() throws Exception {
+ File baseDir = fileFromBuildTestResource("dockerignore/IgnoreAllBut");
+ Dockerfile dockerfile = new Dockerfile(new File(baseDir, "Dockerfile"), baseDir);
+ Dockerfile.ScannedResult result = dockerfile.parse();
+ Collection filesToAdd = transform(result.filesToAdd, TO_FILE_NAMES);
+
+ assertThat(filesToAdd,
+ containsInAnyOrder("Dockerfile", "foo.jar"));
+ }
+
@Test
public void nestedDirsPatterns() throws Exception {
File baseDir = fileFromBuildTestResource("dockerignore/NestedDirsDockerignore");
diff --git a/src/test/java/com/github/dockerjava/netty/handler/FramedResponseStreamHandlerTest.java b/src/test/java/com/github/dockerjava/netty/handler/FramedResponseStreamHandlerTest.java
new file mode 100644
index 000000000..7724b666a
--- /dev/null
+++ b/src/test/java/com/github/dockerjava/netty/handler/FramedResponseStreamHandlerTest.java
@@ -0,0 +1,184 @@
+package com.github.dockerjava.netty.handler;
+
+import com.github.dockerjava.api.model.Frame;
+import com.github.dockerjava.api.async.ResultCallback;
+import com.github.dockerjava.netty.handler.FramedResponseStreamHandler;
+import java.io.Closeable;
+import java.util.ArrayList;
+import java.util.List;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class FramedResponseStreamHandlerTest {
+
+ public class MockedResponseHandler implements ResultCallback {
+
+ public List frames = new ArrayList ();
+ public List exceptions = new ArrayList();
+
+ @Override
+ public void close() {
+ }
+
+ @Override
+ public void onStart(Closeable closeable) {
+ }
+
+ @Override
+ public void onNext(Frame object) {
+ frames.add(object);
+ }
+
+ @Override
+ public void onError(Throwable throwable) {
+ exceptions.add(throwable);
+ }
+
+ @Override
+ public void onComplete() {
+ }
+ }
+
+
+ @Test
+ public void channelRead0emptyHeaderCount() throws Exception {
+
+ // Arrange
+ final MockedResponseHandler responseHandler = new MockedResponseHandler();
+ final FramedResponseStreamHandler objectUnderTest = new FramedResponseStreamHandler(responseHandler);
+ byte[] msg = {};
+
+ // Act
+ objectUnderTest.channelRead0(Mockito.mock(ChannelHandlerContext.class), Unpooled.wrappedBuffer(msg));
+
+ // Assert result
+ assertTrue(responseHandler.frames.isEmpty());
+ }
+
+ @Test
+ public void channelRead0headerTooSmall() throws Exception {
+
+ // Arrange
+ final MockedResponseHandler responseHandler = new MockedResponseHandler();
+ final FramedResponseStreamHandler objectUnderTest = new FramedResponseStreamHandler(responseHandler);
+ byte[] msg = {0};
+
+ // Act
+ objectUnderTest.channelRead0(Mockito.mock(ChannelHandlerContext.class), Unpooled.wrappedBuffer(msg));
+
+ // Assert result
+ assertTrue(responseHandler.frames.isEmpty());
+ }
+
+ @Test
+ public void channelRead0rawStream() throws Exception {
+
+ // Arrange
+ final MockedResponseHandler responseHandler = new MockedResponseHandler();
+ final FramedResponseStreamHandler objectUnderTest = new FramedResponseStreamHandler(responseHandler);
+ byte[] msg = {3, 0, 0, 0, 0, 0, 0, 0, 0};
+
+ // Act
+ objectUnderTest.channelRead0(Mockito.mock(ChannelHandlerContext.class), Unpooled.wrappedBuffer(msg));
+
+ // Assert result
+ assertEquals(responseHandler.frames.get(0).toString(), "RAW: ");
+ }
+
+ @Test
+ public void channelRead0emptyNonRaw() throws Exception {
+
+ // Arrange
+ final MockedResponseHandler responseHandler = new MockedResponseHandler();
+ final FramedResponseStreamHandler objectUnderTest = new FramedResponseStreamHandler(responseHandler);
+ byte[] msg = {0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+ // Act
+ objectUnderTest.channelRead0(Mockito.mock(ChannelHandlerContext.class), Unpooled.wrappedBuffer(msg));
+
+ // Assert result
+ assertTrue(responseHandler.frames.isEmpty());
+ }
+
+ @Test
+ public void channelRead0stdIn() throws Exception {
+
+ // Arrange
+ final MockedResponseHandler responseHandler = new MockedResponseHandler();
+ final FramedResponseStreamHandler objectUnderTest = new FramedResponseStreamHandler(responseHandler);
+ byte[] msg = {0, 0, 0, 0, 0, 0, 0, 1, 0};
+
+ // Act
+ objectUnderTest.channelRead0(Mockito.mock(ChannelHandlerContext.class), Unpooled.wrappedBuffer(msg));
+
+ // Assert result
+ assertEquals(responseHandler.frames.get(0).toString(), "STDIN: ");
+ }
+
+ @Test
+ public void channelRead0stdOut() throws Exception {
+
+ // Arrange
+ final MockedResponseHandler responseHandler = new MockedResponseHandler();
+ final FramedResponseStreamHandler objectUnderTest = new FramedResponseStreamHandler(responseHandler);
+ byte[] msg = {1, 0, 0, 0, 0, 0, 0, 1, 0};
+
+ // Act
+ objectUnderTest.channelRead0(Mockito.mock(ChannelHandlerContext.class), Unpooled.wrappedBuffer(msg));
+
+ // Assert result
+ assertEquals(responseHandler.frames.get(0).toString(), "STDOUT: ");
+ }
+
+ @Test
+ public void channelRead0stdErr() throws Exception {
+
+ // Arrange
+ final MockedResponseHandler responseHandler = new MockedResponseHandler();
+ final FramedResponseStreamHandler objectUnderTest = new FramedResponseStreamHandler(responseHandler);
+ byte[] msg = {2, 0, 0, 0, 0, 0, 0, 1, 0};
+
+ // Act
+ objectUnderTest.channelRead0(Mockito.mock(ChannelHandlerContext.class), Unpooled.wrappedBuffer(msg));
+
+ // Assert result
+ assertEquals(responseHandler.frames.get(0).toString(), "STDERR: ");
+ }
+
+ @Test
+ public void channelRead0largePayload() throws Exception {
+
+ // Arrange
+ final MockedResponseHandler responseHandler = new MockedResponseHandler();
+ final FramedResponseStreamHandler objectUnderTest = new FramedResponseStreamHandler(responseHandler);
+ byte[] msg = {1, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 2, 0};
+
+ // Act
+ objectUnderTest.channelRead0(Mockito.mock(ChannelHandlerContext.class), Unpooled.wrappedBuffer(msg));
+
+ // Assert result
+ assertEquals(responseHandler.frames.get(0).toString(), "STDOUT: ");
+ }
+
+ @Test
+ public void exceptionCaught() throws Exception {
+
+ // Arrange
+ final MockedResponseHandler responseHandler = new MockedResponseHandler();
+ final FramedResponseStreamHandler objectUnderTest = new FramedResponseStreamHandler(responseHandler);
+ final Exception exception = new Exception();
+ final Throwable throwable = new Throwable();
+ throwable.initCause(exception);
+
+ // Act
+ objectUnderTest.exceptionCaught(Mockito.mock(ChannelHandlerContext.class), throwable);
+
+ // Assert result
+ assertEquals(responseHandler.exceptions.get(0).getCause(), exception);
+ }
+}
diff --git a/src/test/java/com/github/dockerjava/utils/RegistryUtils.java b/src/test/java/com/github/dockerjava/utils/RegistryUtils.java
index ea78795a2..e0251023c 100644
--- a/src/test/java/com/github/dockerjava/utils/RegistryUtils.java
+++ b/src/test/java/com/github/dockerjava/utils/RegistryUtils.java
@@ -15,6 +15,7 @@
import java.io.File;
import java.util.concurrent.TimeUnit;
+import static com.github.dockerjava.api.model.HostConfig.newHostConfig;
import static com.github.dockerjava.junit.DockerRule.DEFAULT_IMAGE;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.not;
@@ -64,7 +65,8 @@ public static synchronized AuthConfig runPrivateRegistry(DockerClient dockerClie
CreateContainerResponse testregistry = dockerClient
.createContainerCmd(imageName + ":2")
.withName(containerName)
- .withPortBindings(new PortBinding(Ports.Binding.bindPort(port), ExposedPort.tcp(5000)))
+ .withHostConfig(newHostConfig()
+ .withPortBindings(new PortBinding(Ports.Binding.bindPort(port), ExposedPort.tcp(5000))))
.withEnv("REGISTRY_AUTH=htpasswd", "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm",
"REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd", "REGISTRY_LOG_LEVEL=debug",
"REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt", "REGISTRY_HTTP_TLS_KEY=/certs/domain.key")
diff --git a/src/test/resources/buildTests/dockerignore/IgnoreAllBut/.dockerignore b/src/test/resources/buildTests/dockerignore/IgnoreAllBut/.dockerignore
new file mode 100644
index 000000000..116300b83
--- /dev/null
+++ b/src/test/resources/buildTests/dockerignore/IgnoreAllBut/.dockerignore
@@ -0,0 +1,3 @@
+*
+!Dockerfile
+!build/libs/foo.jar
\ No newline at end of file
diff --git a/src/test/resources/buildTests/dockerignore/IgnoreAllBut/Dockerfile b/src/test/resources/buildTests/dockerignore/IgnoreAllBut/Dockerfile
new file mode 100644
index 000000000..617801170
--- /dev/null
+++ b/src/test/resources/buildTests/dockerignore/IgnoreAllBut/Dockerfile
@@ -0,0 +1 @@
+FROM ubuntu:18.04
diff --git a/src/test/resources/buildTests/dockerignore/IgnoreAllBut/README.MD b/src/test/resources/buildTests/dockerignore/IgnoreAllBut/README.MD
new file mode 100644
index 000000000..ac11abdc4
--- /dev/null
+++ b/src/test/resources/buildTests/dockerignore/IgnoreAllBut/README.MD
@@ -0,0 +1 @@
+DO NOT WANT THIS IN THE DOCKER
diff --git a/src/test/resources/buildTests/dockerignore/IgnoreAllBut/build/libs/foo.jar b/src/test/resources/buildTests/dockerignore/IgnoreAllBut/build/libs/foo.jar
new file mode 100644
index 000000000..4d6bf796e
--- /dev/null
+++ b/src/test/resources/buildTests/dockerignore/IgnoreAllBut/build/libs/foo.jar
@@ -0,0 +1 @@
+foo.jar
\ No newline at end of file
diff --git a/src/test/resources/buildTests/dockerignore/IgnoreAllBut/test/bar.txt b/src/test/resources/buildTests/dockerignore/IgnoreAllBut/test/bar.txt
new file mode 100644
index 000000000..c7152c4d8
--- /dev/null
+++ b/src/test/resources/buildTests/dockerignore/IgnoreAllBut/test/bar.txt
@@ -0,0 +1 @@
+FILE
diff --git a/src/test/resources/com/github/dockerjava/api/command/inspectContainerResponse_full_1_26a.json b/src/test/resources/com/github/dockerjava/api/command/inspectContainerResponse_full_1_26a.json
index 9c505c04b..2f3428d7a 100644
--- a/src/test/resources/com/github/dockerjava/api/command/inspectContainerResponse_full_1_26a.json
+++ b/src/test/resources/com/github/dockerjava/api/command/inspectContainerResponse_full_1_26a.json
@@ -36,7 +36,7 @@
"Memory" : 0,
"MemorySwap" : 0,
"CpuQuota" : 0,
- "OomScoreAdj" : false,
+ "OomScoreAdj" : 500,
"MemoryReservation" : 0
},
"Id" : "58fd1abe8e43a65fb6231b76a9678e7bb4e91686f838945e782a4b74119ce959",
diff --git a/src/test/resources/samples/1.23/other/AuthConfig/docs1.json b/src/test/resources/samples/1.23/other/AuthConfig/docs1.json
new file mode 100644
index 000000000..1ebc88193
--- /dev/null
+++ b/src/test/resources/samples/1.23/other/AuthConfig/docs1.json
@@ -0,0 +1,4 @@
+{
+ "auth": "YWRtaW46",
+ "identitytoken": "1cba468e-8cbe-4c55-9098-2c2ed769e885"
+}
\ No newline at end of file
diff --git a/src/test/resources/samples/1.25/images/windowsImage/doc.json b/src/test/resources/samples/1.25/images/windowsImage/doc.json
new file mode 100644
index 000000000..e7b68c078
--- /dev/null
+++ b/src/test/resources/samples/1.25/images/windowsImage/doc.json
@@ -0,0 +1,72 @@
+{
+ "Id": "sha256:105d76d0f40e38427c63023ffe649bf36fa85058d3469551e43e4dcc2431fb31",
+ "RepoTags": [
+ "microsoft/nanoserver:latest"
+ ],
+ "RepoDigests": [
+ "microsoft/nanoserver@sha256:aee7d4330fe3dc5987c808f647441c16ed2fa1c7d9c6ef49d6498e5c9860b50b"
+ ],
+ "Parent": "",
+ "Comment": "",
+ "Created": "2016-09-22T02:39:30.9154862-07:00",
+ "Container": "",
+ "ContainerConfig": {
+ "Hostname": "",
+ "Domainname": "",
+ "User": "",
+ "AttachStdin": false,
+ "AttachStdout": false,
+ "AttachStderr": false,
+ "Tty": false,
+ "OpenStdin": false,
+ "StdinOnce": false,
+ "Env": null,
+ "Cmd": null,
+ "Image": "",
+ "Volumes": null,
+ "WorkingDir": "",
+ "Entrypoint": null,
+ "OnBuild": null,
+ "Labels": null
+ },
+ "DockerVersion": "",
+ "Author": "",
+ "Config": {
+ "Hostname": "",
+ "Domainname": "",
+ "User": "",
+ "AttachStdin": false,
+ "AttachStdout": false,
+ "AttachStderr": false,
+ "Tty": false,
+ "OpenStdin": false,
+ "StdinOnce": false,
+ "Env": null,
+ "Cmd": [
+ "c:\\windows\\system32\\cmd.exe"
+ ],
+ "Image": "",
+ "Volumes": null,
+ "WorkingDir": "",
+ "Entrypoint": null,
+ "OnBuild": null,
+ "Labels": null
+ },
+ "Architecture": "",
+ "Os": "windows",
+ "OsVersion": "10.0.14393",
+ "Size": 651862727,
+ "VirtualSize": 651862727,
+ "GraphDriver": {
+ "Name": "windowsfilter",
+ "Data": {
+ "dir": "C:\\control\\windowsfilter\\6fe6a289b98276a6a5ca0345156ca61d7b38f3da6bb49ef95af1d0f1ac37e5bf"
+ }
+ },
+ "RootFS": {
+ "Type": "layers",
+ "Layers": [
+ "sha256:342d4e407550c52261edd20cd901b5ce438f0b1e940336de3978210612365063"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/samples/1.25/other/AuthConfig/orchestrators.json b/src/test/resources/samples/1.25/other/AuthConfig/orchestrators.json
new file mode 100644
index 000000000..3b67b1941
--- /dev/null
+++ b/src/test/resources/samples/1.25/other/AuthConfig/orchestrators.json
@@ -0,0 +1,3 @@
+{
+ "stackOrchestrator" : "kubernetes"
+}
\ No newline at end of file
diff --git a/src/test/resources/samples/1.27/containers/container/stats/stats1.json b/src/test/resources/samples/1.27/containers/container/stats/stats1.json
index cb5f324f0..5a80cd99c 100644
--- a/src/test/resources/samples/1.27/containers/container/stats/stats1.json
+++ b/src/test/resources/samples/1.27/containers/container/stats/stats1.json
@@ -5,32 +5,68 @@
"current":2
},
"blkio_stats":{
- "io_service_bytes_recursive": [
+ "io_service_bytes_recursive":[
{
- "major": 8,
- "minor": "0",
- "op": "Read",
- "value": 26214
+ "major":259,
+ "minor":0,
+ "op":"Read",
+ "value":823296
},
{
- "major": 8,
- "minor": "0",
- "op": "Write",
- "value": 26214
+ "major":259,
+ "minor":0,
+ "op":"Write",
+ "value":122880
+ },
+ {
+ "major":259,
+ "minor":0,
+ "op":"Sync",
+ "value":835584
+ },
+ {
+ "major":259,
+ "minor":0,
+ "op":"Async",
+ "value":110592
+ },
+ {
+ "major":259,
+ "minor":0,
+ "op":"Total",
+ "value":946176
}
],
- "io_serviced_recursive": [
+ "io_serviced_recursive":[
+ {
+ "major":259,
+ "minor":0,
+ "op":"Read",
+ "value":145
+ },
+ {
+ "major":259,
+ "minor":0,
+ "op":"Write",
+ "value":4
+ },
+ {
+ "major":259,
+ "minor":0,
+ "op":"Sync",
+ "value":148
+ },
{
- "major": 8,
- "minor": 0,
- "op": "Read",
- "value": 41771
+ "major":259,
+ "minor":0,
+ "op":"Async",
+ "value":1
},
{
- "major": 8,
- "minor": 0,
- "op": "Write",
- "value": 72796
+ "major":259,
+ "minor":0,
+ "op":"Total",
+ "value":149
}
],
"io_queue_recursive":[
@@ -135,7 +171,8 @@
"unevictable":0,
"writeback":0
},
- "limit":2095874048
+ "limit":2095874048,
+ "failcnt":0
},
"name":"/gallant_hamilton",
"id":"b581d78b03e41d81c9fe941f03f5d35e23733ff96370456b58d2906e002b0deb",
diff --git a/src/test/resources/samples/1.38/containers/inspect/lcow.json b/src/test/resources/samples/1.38/containers/inspect/lcow.json
new file mode 100644
index 000000000..4e7725def
--- /dev/null
+++ b/src/test/resources/samples/1.38/containers/inspect/lcow.json
@@ -0,0 +1,169 @@
+{
+ "AppArmorProfile": "",
+ "Args": [],
+ "Config": {
+ "AttachStderr": true,
+ "AttachStdin": true,
+ "AttachStdout": true,
+ "Cmd": [
+ "cmd"
+ ],
+ "Domainname": "",
+ "Entrypoint": null,
+ "Env": null,
+ "Hostname": "35da02ca897b",
+ "Image": "microsoft/nanoserver",
+ "Labels": {},
+ "OnBuild": null,
+ "OpenStdin": true,
+ "StdinOnce": true,
+ "Tty": true,
+ "User": "",
+ "Volumes": null,
+ "WorkingDir": ""
+ },
+ "Created": "2018-09-18T10:37:25.0470753Z",
+ "Driver": "windowsfilter",
+ "ExecIDs": null,
+ "GraphDriver": {
+ "Data": {
+ "dir": "C:\\ProgramData\\Docker\\windowsfilter\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556"
+ },
+ "Name": "windowsfilter"
+ },
+ "HostConfig": {
+ "AutoRemove": true,
+ "Binds": null,
+ "BlkioDeviceReadBps": null,
+ "BlkioDeviceReadIOps": null,
+ "BlkioDeviceWriteBps": null,
+ "BlkioDeviceWriteIOps": null,
+ "BlkioWeight": 0,
+ "BlkioWeightDevice": [],
+ "CapAdd": null,
+ "CapDrop": null,
+ "Cgroup": "",
+ "CgroupParent": "",
+ "ConsoleSize": [
+ 50,
+ 173
+ ],
+ "ContainerIDFile": "",
+ "CpuCount": 0,
+ "CpuPercent": 0,
+ "CpuPeriod": 0,
+ "CpuQuota": 0,
+ "CpuRealtimePeriod": 0,
+ "CpuRealtimeRuntime": 0,
+ "CpuShares": 0,
+ "CpusetCpus": "",
+ "CpusetMems": "",
+ "DeviceCgroupRules": null,
+ "Devices": [],
+ "DiskQuota": 0,
+ "Dns": [],
+ "DnsOptions": [],
+ "DnsSearch": [],
+ "ExtraHosts": null,
+ "GroupAdd": null,
+ "IOMaximumBandwidth": 0,
+ "IOMaximumIOps": 0,
+ "IpcMode": "",
+ "Isolation": "hyperv",
+ "KernelMemory": 0,
+ "Links": null,
+ "LogConfig": {
+ "Config": {},
+ "Type": "json-file"
+ },
+ "MaskedPaths": null,
+ "Memory": 0,
+ "MemoryReservation": 0,
+ "MemorySwap": 0,
+ "MemorySwappiness": null,
+ "NanoCpus": 0,
+ "NetworkMode": "default",
+ "OomKillDisable": false,
+ "OomScoreAdj": 0,
+ "PidMode": "",
+ "PidsLimit": 0,
+ "PortBindings": {},
+ "Privileged": false,
+ "PublishAllPorts": false,
+ "ReadonlyPaths": null,
+ "ReadonlyRootfs": false,
+ "RestartPolicy": {
+ "MaximumRetryCount": 0,
+ "Name": "no"
+ },
+ "SecurityOpt": null,
+ "ShmSize": 0,
+ "UTSMode": "",
+ "Ulimits": null,
+ "UsernsMode": "",
+ "VolumeDriver": "",
+ "VolumesFrom": null
+ },
+ "HostnamePath": "",
+ "HostsPath": "",
+ "Id": "35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556",
+ "Image": "sha256:1381511ec0122f197b6abff5bc0692bef19943ddafd6680eff41197afa3a6dda",
+ "LogPath": "C:\\ProgramData\\Docker\\containers\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556-json.log",
+ "MountLabel": "",
+ "Mounts": [],
+ "Name": "/cranky_clarke",
+ "NetworkSettings": {
+ "Bridge": "",
+ "EndpointID": "",
+ "Gateway": "",
+ "GlobalIPv6Address": "",
+ "GlobalIPv6PrefixLen": 0,
+ "HairpinMode": false,
+ "IPAddress": "",
+ "IPPrefixLen": 0,
+ "IPv6Gateway": "",
+ "LinkLocalIPv6Address": "",
+ "LinkLocalIPv6PrefixLen": 0,
+ "MacAddress": "",
+ "Networks": {
+ "nat": {
+ "Aliases": null,
+ "DriverOpts": null,
+ "EndpointID": "493b77d6fe7e3b92435b1eb01461fde669781330deb84a9cbada360db8997ebc",
+ "Gateway": "172.17.18.1",
+ "GlobalIPv6Address": "",
+ "GlobalIPv6PrefixLen": 0,
+ "IPAMConfig": null,
+ "IPAddress": "172.17.18.123",
+ "IPPrefixLen": 16,
+ "IPv6Gateway": "",
+ "Links": null,
+ "MacAddress": "00:aa:ff:cf:dd:09",
+ "NetworkID": "398c0e206dd677ed4a6566f9de458311f5767d8c7a8b963275490ab64c5d10a7"
+ }
+ },
+ "Ports": {},
+ "SandboxID": "35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556",
+ "SandboxKey": "35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556",
+ "SecondaryIPAddresses": null,
+ "SecondaryIPv6Addresses": null
+ },
+ "Path": "cmd",
+ "Platform": "windows",
+ "ProcessLabel": "",
+ "ResolvConfPath": "",
+ "RestartCount": 0,
+ "State": {
+ "Dead": false,
+ "Error": "",
+ "ExitCode": 0,
+ "FinishedAt": "0001-01-01T00:00:00Z",
+ "OOMKilled": false,
+ "Paused": false,
+ "Pid": 1588,
+ "Restarting": false,
+ "Running": true,
+ "StartedAt": "2018-09-18T10:37:28.3668368Z",
+ "Status": "running"
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/samples/1.38/info/lcow.json b/src/test/resources/samples/1.38/info/lcow.json
new file mode 100644
index 000000000..7ab600449
--- /dev/null
+++ b/src/test/resources/samples/1.38/info/lcow.json
@@ -0,0 +1,93 @@
+{
+ "Architecture": "x86_64",
+ "BridgeNfIp6tables": true,
+ "BridgeNfIptables": true,
+ "CPUSet": false,
+ "CPUShares": false,
+ "CgroupDriver": "",
+ "ClusterAdvertise": "",
+ "ClusterStore": "",
+ "ContainerdCommit": {
+ "Expected": "",
+ "ID": ""
+ },
+ "Containers": 3,
+ "ContainersPaused": 0,
+ "ContainersRunning": 0,
+ "ContainersStopped": 3,
+ "CpuCfsPeriod": false,
+ "CpuCfsQuota": false,
+ "Debug": true,
+ "DefaultRuntime": "",
+ "DockerRootDir": "C:\\ProgramData\\Docker",
+ "Driver": "windowsfilter (windows) lcow (linux)",
+ "DriverStatus": [["Windows", ""], ["LCOW", ""]],
+ "ExperimentalBuild": true,
+ "GenericResources": null,
+ "HttpProxy": "",
+ "HttpsProxy": "",
+ "ID": "ZOGT:VB24:YEPZ:Y7HU:JHPB:WNUE:UYQG:7YRY:VLZV:FLWV:R65B:ICZG",
+ "IPv4Forwarding": true,
+ "Images": 2,
+ "IndexServerAddress": "https://index.docker.io/v1/",
+ "InitBinary": "",
+ "InitCommit": {
+ "Expected": "",
+ "ID": ""
+ },
+ "Isolation": "hyperv",
+ "KernelMemory": false,
+ "KernelVersion": "10.0 17134 (17134.1.amd64fre.rs4_release.180410-1804)",
+ "Labels": [],
+ "LiveRestoreEnabled": false,
+ "LoggingDriver": "json-file",
+ "MemTotal": 68684476416,
+ "MemoryLimit": false,
+ "NCPU": 8,
+ "NEventsListener": 1,
+ "NFd": -1,
+ "NGoroutines": 28,
+ "Name": "somename",
+ "NoProxy": "",
+ "OSType": "windows",
+ "OomKillDisable": false,
+ "OperatingSystem": "Windows 10 Pro Version 1803 (OS Build 17134.228)",
+ "Plugins": {
+ "Authorization": null,
+ "Log": ["awslogs", "etwlogs", "fluentd", "gelf", "json-file", "logentries", "splunk", "syslog"],
+ "Network": ["ics", "l2bridge", "l2tunnel", "nat", "null", "overlay", "transparent"],
+ "Volume": ["local"]
+ },
+ "RegistryConfig": {
+ "AllowNondistributableArtifactsCIDRs": [],
+ "AllowNondistributableArtifactsHostnames": [],
+ "IndexConfigs": {
+ "docker.io": {
+ "Mirrors": [],
+ "Name": "docker.io",
+ "Official": true,
+ "Secure": true
+ }
+ },
+ "InsecureRegistryCIDRs": ["127.0.0.0/8"],
+ "Mirrors": []
+ },
+ "RuncCommit": {
+ "Expected": "",
+ "ID": ""
+ },
+ "Runtimes": null,
+ "SecurityOptions": [],
+ "ServerVersion": "18.06.1-ce",
+ "SwapLimit": false,
+ "Swarm": {
+ "ControlAvailable": false,
+ "Error": "",
+ "LocalNodeState": "inactive",
+ "NodeAddr": "",
+ "NodeID": "",
+ "RemoteManagers": null
+ },
+ "SystemStatus": null,
+ "SystemTime": "2018-09-14T09:40:05.1369294+02:00"
+}
diff --git a/src/test/resources/samples/1.38/version/lcow.json b/src/test/resources/samples/1.38/version/lcow.json
new file mode 100644
index 000000000..21f496823
--- /dev/null
+++ b/src/test/resources/samples/1.38/version/lcow.json
@@ -0,0 +1,31 @@
+{
+ "ApiVersion": "1.38",
+ "Arch": "amd64",
+ "BuildTime": "2018-08-21T17:36:40.000000000+00:00",
+ "Components": [{
+ "Details": {
+ "ApiVersion": "1.38",
+ "Arch": "amd64",
+ "BuildTime": "2018-08-21T17:36:40.000000000+00:00",
+ "Experimental": "true",
+ "GitCommit": "e68fc7a",
+ "GoVersion": "go1.10.3",
+ "KernelVersion": "10.0 17134 (17134.1.amd64fre.rs4_release.180410-1804)",
+ "MinAPIVersion": "1.24",
+ "Os": "windows"
+ },
+ "Name": "Engine",
+ "Version": "18.06.1-ce"
+ }
+ ],
+ "Experimental": true,
+ "GitCommit": "e68fc7a",
+ "GoVersion": "go1.10.3",
+ "KernelVersion": "10.0 17134 (17134.1.amd64fre.rs4_release.180410-1804)",
+ "MinAPIVersion": "1.24",
+ "Os": "windows",
+ "Platform": {
+ "Name": ""
+ },
+ "Version": "18.06.1-ce"
+}