Merge pull request #119 from jmccann/remove_temp_layers

Remove temp tag from build and prune afterwards
This commit is contained in:
Brad Rydzewski 2017-05-15 16:43:43 +02:00 committed by GitHub
commit 4904d5cf56
1 changed files with 9 additions and 2 deletions

View File

@ -112,7 +112,7 @@ func (p Plugin) Exec() error {
var cmds []*exec.Cmd
cmds = append(cmds, commandVersion()) // docker version
cmds = append(cmds, commandInfo()) // docker info
cmds = append(cmds, commandDockerPrune()) // cleanup docker
cmds = append(cmds, commandBuild(p.Build)) // docker build
for _, tag := range p.Build.Tags {
@ -123,6 +123,9 @@ func (p Plugin) Exec() error {
}
}
cmds = append(cmds, commandRmi(p.Build.Name)) // docker rmi
cmds = append(cmds, commandPrune()) // docker system prune -f
// execute all commands in batch mode.
for _, cmd := range cmds {
cmd.Stdout = os.Stdout
@ -291,10 +294,14 @@ func commandDaemon(daemon Daemon) *exec.Cmd {
return exec.Command(dockerdExe, args...)
}
func commandDockerPrune() *exec.Cmd {
func commandPrune() *exec.Cmd {
return exec.Command(dockerExe, "system", "prune", "-f")
}
func commandRmi(tag string) *exec.Cmd {
return exec.Command(dockerExe, "rmi", tag)
}
// trace writes each command to stdout with the command wrapped in an xml
// tag so that it can be extracted and displayed in the logs.
func trace(cmd *exec.Cmd) {