diff --git a/src/main/java/com/github/dockerjava/client/command/BuildImgCmd.java b/src/main/java/com/github/dockerjava/client/command/BuildImgCmd.java index 6070fbb92..191073511 100644 --- a/src/main/java/com/github/dockerjava/client/command/BuildImgCmd.java +++ b/src/main/java/com/github/dockerjava/client/command/BuildImgCmd.java @@ -45,6 +45,8 @@ public class BuildImgCmd extends AbstrDockerCmd { private InputStream tarInputStream = null; private String tag; private boolean noCache; + private boolean remove = true; + private boolean quiet; public BuildImgCmd(File dockerFolder) { @@ -68,11 +70,23 @@ public BuildImgCmd withNoCache(boolean noCache) { return this; } + public BuildImgCmd withRemove(boolean rm) { + this.remove = rm; + return this; + } + + public BuildImgCmd withQuiet(boolean quiet) { + this.quiet = quiet; + return this; + } + @Override public String toString() { return new StringBuilder("build ") .append(tag != null ? "-t " + tag + " " : "") .append(noCache ? "--nocache=true " : "") + .append(quiet ? "--quiet=true " : "") + .append(!remove ? "--rm=false " : "") .append(dockerFolder != null ? dockerFolder.getPath() : "-") .toString(); } @@ -98,6 +112,12 @@ protected ClientResponse callDocker(final InputStream dockerFolderTarInputStream if (noCache) { params.add("nocache", "true"); } + if (remove) { + params.add("rm", "true"); + } + if (quiet) { + params.add("q", "true"); + } WebResource webResource = baseResource.path("/build").queryParams(params);