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 <cristian.staretu@gmail.com> (github: unclejack)
This commit is contained in:
parent
e39299ca1d
commit
667e2bd4ea
9 changed files with 1400 additions and 10 deletions
|
@ -110,6 +110,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
|||
suppressOutput := cmd.Bool([]string{"q", "-quiet"}, false, "Suppress the verbose output generated by the containers")
|
||||
noCache := cmd.Bool([]string{"#no-cache", "-no-cache"}, false, "Do not use cache when building the image")
|
||||
rm := cmd.Bool([]string{"#rm", "-rm"}, true, "Remove intermediate containers after a successful build")
|
||||
forceRm := cmd.Bool([]string{"-force-rm"}, false, "Always remove intermediate containers, even after unsuccessful builds")
|
||||
if err := cmd.Parse(args); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -199,6 +200,10 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
|||
v.Set("rm", "1")
|
||||
}
|
||||
|
||||
if *forceRm {
|
||||
v.Set("forcerm", "1")
|
||||
}
|
||||
|
||||
cli.LoadConfigFile()
|
||||
|
||||
headers := http.Header(make(map[string][]string))
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
APIVERSION version.Version = "1.11"
|
||||
APIVERSION version.Version = "1.12"
|
||||
DEFAULTHTTPHOST = "127.0.0.1"
|
||||
DEFAULTUNIXSOCKET = "/var/run/docker.sock"
|
||||
)
|
||||
|
|
|
@ -903,12 +903,17 @@ func postBuild(eng *engine.Engine, version version.Version, w http.ResponseWrite
|
|||
} else {
|
||||
job.Stdout.Add(utils.NewWriteFlusher(w))
|
||||
}
|
||||
if r.FormValue("forcerm") == "1" && version.GreaterThanOrEqualTo("1.12") {
|
||||
job.Setenv("rm", "1")
|
||||
} else {
|
||||
job.Setenv("rm", r.FormValue("rm"))
|
||||
}
|
||||
job.Stdin.Add(r.Body)
|
||||
job.Setenv("remote", r.FormValue("remote"))
|
||||
job.Setenv("t", r.FormValue("t"))
|
||||
job.Setenv("q", r.FormValue("q"))
|
||||
job.Setenv("nocache", r.FormValue("nocache"))
|
||||
job.Setenv("rm", r.FormValue("rm"))
|
||||
job.Setenv("forcerm", r.FormValue("forcerm"))
|
||||
job.SetenvJson("authConfig", authConfig)
|
||||
job.SetenvJson("configFile", configFile)
|
||||
|
||||
|
|
|
@ -20,13 +20,23 @@ page_keywords: API, Docker, rcli, REST, documentation
|
|||
|
||||
|
||||
|
||||
The current version of the API is v1.11
|
||||
The current version of the API is v1.12
|
||||
|
||||
Calling /images/<name>/insert is the same as calling
|
||||
/v1.11/images/<name>/insert
|
||||
/v1.12/images/<name>/insert
|
||||
|
||||
You can still call an old version of the api using
|
||||
/v1.11/images/<name>/insert
|
||||
/v1.12/images/<name>/insert
|
||||
|
||||
## v1.12
|
||||
|
||||
### Full Documentation
|
||||
|
||||
[*Docker Remote API v1.12*](/reference/api/docker_remote_api_v1.12/)
|
||||
|
||||
### What's new
|
||||
|
||||
docker build now has support for the `forcerm` parameter to always remove containers
|
||||
|
||||
## v1.11
|
||||
|
||||
|
|
1363
docs/sources/reference/api/docker_remote_api_v1.12.md
Normal file
1363
docs/sources/reference/api/docker_remote_api_v1.12.md
Normal file
File diff suppressed because it is too large
Load diff
|
@ -192,6 +192,7 @@ To kill the container, use `docker kill`.
|
|||
|
||||
Build a new container image from the source code at PATH
|
||||
|
||||
--force-rm=false Always remove intermediate containers, even after unsuccessful builds
|
||||
--no-cache=false Do not use cache when building the image
|
||||
-q, --quiet=false Suppress the verbose output generated by the containers
|
||||
--rm=true Remove intermediate containers after a successful build
|
||||
|
|
|
@ -394,7 +394,7 @@ func buildImage(context testContextTemplate, t *testing.T, eng *engine.Engine, u
|
|||
}
|
||||
dockerfile := constructDockerfile(context.dockerfile, ip, port)
|
||||
|
||||
buildfile := server.NewBuildFile(srv, ioutil.Discard, ioutil.Discard, false, useCache, false, ioutil.Discard, utils.NewStreamFormatter(false), nil, nil)
|
||||
buildfile := server.NewBuildFile(srv, ioutil.Discard, ioutil.Discard, false, useCache, false, false, ioutil.Discard, utils.NewStreamFormatter(false), nil, nil)
|
||||
id, err := buildfile.Build(context.Archive(dockerfile, t))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -828,7 +828,7 @@ func TestForbiddenContextPath(t *testing.T) {
|
|||
}
|
||||
dockerfile := constructDockerfile(context.dockerfile, ip, port)
|
||||
|
||||
buildfile := server.NewBuildFile(srv, ioutil.Discard, ioutil.Discard, false, true, false, ioutil.Discard, utils.NewStreamFormatter(false), nil, nil)
|
||||
buildfile := server.NewBuildFile(srv, ioutil.Discard, ioutil.Discard, false, true, false, false, ioutil.Discard, utils.NewStreamFormatter(false), nil, nil)
|
||||
_, err = buildfile.Build(context.Archive(dockerfile, t))
|
||||
|
||||
if err == nil {
|
||||
|
@ -874,7 +874,7 @@ func TestBuildADDFileNotFound(t *testing.T) {
|
|||
}
|
||||
dockerfile := constructDockerfile(context.dockerfile, ip, port)
|
||||
|
||||
buildfile := server.NewBuildFile(mkServerFromEngine(eng, t), ioutil.Discard, ioutil.Discard, false, true, false, ioutil.Discard, utils.NewStreamFormatter(false), nil, nil)
|
||||
buildfile := server.NewBuildFile(mkServerFromEngine(eng, t), ioutil.Discard, ioutil.Discard, false, true, false, false, ioutil.Discard, utils.NewStreamFormatter(false), nil, nil)
|
||||
_, err = buildfile.Build(context.Archive(dockerfile, t))
|
||||
|
||||
if err == nil {
|
||||
|
|
|
@ -50,6 +50,7 @@ type buildFile struct {
|
|||
verbose bool
|
||||
utilizeCache bool
|
||||
rm bool
|
||||
forceRm bool
|
||||
|
||||
authConfig *registry.AuthConfig
|
||||
configFile *registry.ConfigFile
|
||||
|
@ -807,6 +808,9 @@ func (b *buildFile) Build(context io.Reader) (string, error) {
|
|||
continue
|
||||
}
|
||||
if err := b.BuildStep(fmt.Sprintf("%d", stepN), line); err != nil {
|
||||
if b.forceRm {
|
||||
b.clearTmp(b.tmpContainers)
|
||||
}
|
||||
return "", err
|
||||
} else if b.rm {
|
||||
b.clearTmp(b.tmpContainers)
|
||||
|
@ -859,7 +863,7 @@ func stripComments(raw []byte) string {
|
|||
return strings.Join(out, "\n")
|
||||
}
|
||||
|
||||
func NewBuildFile(srv *Server, outStream, errStream io.Writer, verbose, utilizeCache, rm bool, outOld io.Writer, sf *utils.StreamFormatter, auth *registry.AuthConfig, authConfigFile *registry.ConfigFile) BuildFile {
|
||||
func NewBuildFile(srv *Server, outStream, errStream io.Writer, verbose, utilizeCache, rm bool, forceRm bool, outOld io.Writer, sf *utils.StreamFormatter, auth *registry.AuthConfig, authConfigFile *registry.ConfigFile) BuildFile {
|
||||
return &buildFile{
|
||||
daemon: srv.daemon,
|
||||
srv: srv,
|
||||
|
@ -871,6 +875,7 @@ func NewBuildFile(srv *Server, outStream, errStream io.Writer, verbose, utilizeC
|
|||
verbose: verbose,
|
||||
utilizeCache: utilizeCache,
|
||||
rm: rm,
|
||||
forceRm: forceRm,
|
||||
sf: sf,
|
||||
authConfig: auth,
|
||||
configFile: authConfigFile,
|
||||
|
|
|
@ -438,6 +438,7 @@ func (srv *Server) Build(job *engine.Job) engine.Status {
|
|||
suppressOutput = job.GetenvBool("q")
|
||||
noCache = job.GetenvBool("nocache")
|
||||
rm = job.GetenvBool("rm")
|
||||
forceRm = job.GetenvBool("forcerm")
|
||||
authConfig = ®istry.AuthConfig{}
|
||||
configFile = ®istry.ConfigFile{}
|
||||
tag string
|
||||
|
@ -496,7 +497,7 @@ func (srv *Server) Build(job *engine.Job) engine.Status {
|
|||
Writer: job.Stdout,
|
||||
StreamFormatter: sf,
|
||||
},
|
||||
!suppressOutput, !noCache, rm, job.Stdout, sf, authConfig, configFile)
|
||||
!suppressOutput, !noCache, rm, forceRm, job.Stdout, sf, authConfig, configFile)
|
||||
id, err := b.Build(context)
|
||||
if err != nil {
|
||||
return job.Error(err)
|
||||
|
|
Loading…
Reference in a new issue