Skip to content

Commit 667e2bd

Browse files
committed
bump remote api to 1.12 & add --force-rm to build
This adds a `--force-rm` flag to docker build which makes the Docker daemon clean up all containers, even when the build has failed. This new flag requires that we bump the remote API, so we also bump the remote API version. Docker-DCO-1.1-Signed-off-by: Cristian Staretu <[email protected]> (github: unclejack)
1 parent e39299c commit 667e2bd

9 files changed

Lines changed: 1400 additions & 10 deletions

File tree

api/client/commands.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
110110
suppressOutput := cmd.Bool([]string{"q", "-quiet"}, false, "Suppress the verbose output generated by the containers")
111111
noCache := cmd.Bool([]string{"#no-cache", "-no-cache"}, false, "Do not use cache when building the image")
112112
rm := cmd.Bool([]string{"#rm", "-rm"}, true, "Remove intermediate containers after a successful build")
113+
forceRm := cmd.Bool([]string{"-force-rm"}, false, "Always remove intermediate containers, even after unsuccessful builds")
113114
if err := cmd.Parse(args); err != nil {
114115
return nil
115116
}
@@ -199,6 +200,10 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
199200
v.Set("rm", "1")
200201
}
201202

203+
if *forceRm {
204+
v.Set("forcerm", "1")
205+
}
206+
202207
cli.LoadConfigFile()
203208

204209
headers := http.Header(make(map[string][]string))

api/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
const (
14-
APIVERSION version.Version = "1.11"
14+
APIVERSION version.Version = "1.12"
1515
DEFAULTHTTPHOST = "127.0.0.1"
1616
DEFAULTUNIXSOCKET = "/var/run/docker.sock"
1717
)

api/server/server.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,12 +903,17 @@ func postBuild(eng *engine.Engine, version version.Version, w http.ResponseWrite
903903
} else {
904904
job.Stdout.Add(utils.NewWriteFlusher(w))
905905
}
906+
if r.FormValue("forcerm") == "1" && version.GreaterThanOrEqualTo("1.12") {
907+
job.Setenv("rm", "1")
908+
} else {
909+
job.Setenv("rm", r.FormValue("rm"))
910+
}
906911
job.Stdin.Add(r.Body)
907912
job.Setenv("remote", r.FormValue("remote"))
908913
job.Setenv("t", r.FormValue("t"))
909914
job.Setenv("q", r.FormValue("q"))
910915
job.Setenv("nocache", r.FormValue("nocache"))
911-
job.Setenv("rm", r.FormValue("rm"))
916+
job.Setenv("forcerm", r.FormValue("forcerm"))
912917
job.SetenvJson("authConfig", authConfig)
913918
job.SetenvJson("configFile", configFile)
914919

docs/sources/reference/api/docker_remote_api.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,23 @@ page_keywords: API, Docker, rcli, REST, documentation
2020

2121

2222

23-
The current version of the API is v1.11
23+
The current version of the API is v1.12
2424

2525
Calling /images/<name>/insert is the same as calling
26-
/v1.11/images/<name>/insert
26+
/v1.12/images/<name>/insert
2727

2828
You can still call an old version of the api using
29-
/v1.11/images/<name>/insert
29+
/v1.12/images/<name>/insert
30+
31+
## v1.12
32+
33+
### Full Documentation
34+
35+
[*Docker Remote API v1.12*](/reference/api/docker_remote_api_v1.12/)
36+
37+
### What's new
38+
39+
docker build now has support for the `forcerm` parameter to always remove containers
3040

3141
## v1.11
3242

0 commit comments

Comments
 (0)