From 5eb8342bf73533f25308874f73d5c1756e75f8a7 Mon Sep 17 00:00:00 2001 From: Sean Fitts Date: Wed, 9 Jul 2014 14:11:33 -0700 Subject: [PATCH] Update BuildImgCmd options to match default client behavior --- .../client/command/BuildImgCmd.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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 5a92fb56f..daca11ae3 100644 --- a/src/main/java/com/github/dockerjava/client/command/BuildImgCmd.java +++ b/src/main/java/com/github/dockerjava/client/command/BuildImgCmd.java @@ -38,6 +38,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) { @@ -61,11 +63,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(); } @@ -91,6 +105,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);