Skip to content

Conversation

unclejack
Copy link
Contributor

@unclejack unclejack commented May 16, 2014

This PR is ready for review.

This adds a --force-rm flag to docker build which makes the Docker daemon clean up all containers, even when the build has failed.

@philips
Copy link
Contributor

philips commented May 16, 2014

Great! Would be happy to test when you have this working.

@@ -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", "-force-rm"}, false, "Always remove intermediate containers, even after unsuccessful builds")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to add the deprecated flag. We can stick with the '--' version

@unclejack
Copy link
Contributor Author

I've made the required changes to the docs, I've added a test and one more commit to add back rm to the 1.10 and 1.11 API docs.

@philips You can try it out already, it only needed docs and tests.

ping @vieux @creack @crosbymichael

@unclejack
Copy link
Contributor Author

I've made the remaining changes and I've added one more batch of cli integration tests.
@vieux You can review the PR.

@vieux
Copy link
Contributor

vieux commented May 19, 2014

Coud you update docs/sources/reference/api/docker_remote_api.md to a **New!** please ?

Otherwise LGTM

unclejack added 6 commits May 19, 2014 22:46
This adds back the rm query parameter to the remote api docs for api
v1.10 and v1.11.

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
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)
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
This makes the remote API version 1.12 and newer default to
automatically deleting intermediate containers when the build has
succeedeed.

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
@unclejack
Copy link
Contributor Author

@vieux Could you take another look, please?

@vieux
Copy link
Contributor

vieux commented May 19, 2014

LGTM

@jamtur01
Copy link
Contributor

Docs LGTM

@crosbymichael
Copy link
Contributor

@unclejack @vieux would it be better to have this as the default or is the flag the right way?

@unclejack
Copy link
Contributor Author

@crosbymichael We're defaulting --rm to true already and this PR makes it the default for the remote API as well so people don't have to specify it for the API.
--force-rm should default to false so we don't remove containers after a failure by default.

@crosbymichael
Copy link
Contributor

@unclejack yes, but why don't we force-rm as the default for --rm? It seems more ppl want these removed anyways and don't care

@unclejack
Copy link
Contributor Author

@crosbymichael It just seems like it might be unexpected to see all the containers deleted without notice upon failure. For example, if you're doing an expensive build (bandwidth, computation and disk io) and there's nothing left behind to debug, it might be annoying to see the container is gone and you have to repeat the build with --force-rm=false.

@crosbymichael
Copy link
Contributor

ok, sounds good. I just wanted to double check to see what you thought

@@ -903,12 +903,20 @@ 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") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you use the getBoolParam and not just check for 1 on these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is ok. The code is doing the same thing for rm below because we need to check for specific values explicitly. This makes it easier to have tri-state values (missing, false, true) for this in the future, just like I've changed --rm to be tri-state (missing with default to true, false and true).

@crosbymichael
Copy link
Contributor

LGTM

crosbymichael added a commit that referenced this pull request May 22, 2014
add --force-rm to clean up after a failed build
@crosbymichael crosbymichael merged commit db1a355 into moby:master May 22, 2014
@unclejack unclejack deleted the improve_build_rm branch May 22, 2014 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docker build should have a --force-rm flag Why was "remove intermediate containers" removed in 1.10 build remote api?
6 participants