Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
| ... | ... |
@@ -77,6 +77,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
| 77 | 77 |
noCache := cmd.Bool([]string{"#no-cache", "-no-cache"}, false, "Do not use cache when building the image")
|
| 78 | 78 |
rm := cmd.Bool([]string{"#rm", "-rm"}, true, "Remove intermediate containers after a successful build")
|
| 79 | 79 |
forceRm := cmd.Bool([]string{"-force-rm"}, false, "Always remove intermediate containers, even after unsuccessful builds")
|
| 80 |
+ pull := cmd.Bool([]string{"-pull"}, false, "Always attempt to pull a newer version of the image")
|
|
| 80 | 81 |
if err := cmd.Parse(args); err != nil {
|
| 81 | 82 |
return nil |
| 82 | 83 |
} |
| ... | ... |
@@ -213,6 +214,9 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
| 213 | 213 |
v.Set("forcerm", "1")
|
| 214 | 214 |
} |
| 215 | 215 |
|
| 216 |
+ if *pull {
|
|
| 217 |
+ v.Set("pull", "1")
|
|
| 218 |
+ } |
|
| 216 | 219 |
cli.LoadConfigFile() |
| 217 | 220 |
|
| 218 | 221 |
headers := http.Header(make(map[string][]string)) |
| ... | ... |
@@ -1016,6 +1016,9 @@ func postBuild(eng *engine.Engine, version version.Version, w http.ResponseWrite |
| 1016 | 1016 |
} else {
|
| 1017 | 1017 |
job.Setenv("rm", r.FormValue("rm"))
|
| 1018 | 1018 |
} |
| 1019 |
+ if r.FormValue("pull") == "1" && version.GreaterThanOrEqualTo("1.16") {
|
|
| 1020 |
+ job.Setenv("pull", "1")
|
|
| 1021 |
+ } |
|
| 1019 | 1022 |
job.Stdin.Add(r.Body) |
| 1020 | 1023 |
job.Setenv("remote", r.FormValue("remote"))
|
| 1021 | 1024 |
job.Setenv("t", r.FormValue("t"))
|
| ... | ... |
@@ -115,6 +115,12 @@ func from(b *Builder, args []string, attributes map[string]bool, original string |
| 115 | 115 |
name := args[0] |
| 116 | 116 |
|
| 117 | 117 |
image, err := b.Daemon.Repositories().LookupImage(name) |
| 118 |
+ if b.Pull {
|
|
| 119 |
+ image, err = b.pullImage(name) |
|
| 120 |
+ if err != nil {
|
|
| 121 |
+ return err |
|
| 122 |
+ } |
|
| 123 |
+ } |
|
| 118 | 124 |
if err != nil {
|
| 119 | 125 |
if b.Daemon.Graph().IsNotExist(err) {
|
| 120 | 126 |
image, err = b.pullImage(name) |
| ... | ... |
@@ -35,6 +35,7 @@ func (b *BuilderJob) CmdBuild(job *engine.Job) engine.Status {
|
| 35 | 35 |
noCache = job.GetenvBool("nocache")
|
| 36 | 36 |
rm = job.GetenvBool("rm")
|
| 37 | 37 |
forceRm = job.GetenvBool("forcerm")
|
| 38 |
+ pull = job.GetenvBool("pull")
|
|
| 38 | 39 |
authConfig = ®istry.AuthConfig{}
|
| 39 | 40 |
configFile = ®istry.ConfigFile{}
|
| 40 | 41 |
tag string |
| ... | ... |
@@ -111,6 +112,7 @@ func (b *BuilderJob) CmdBuild(job *engine.Job) engine.Status {
|
| 111 | 111 |
UtilizeCache: !noCache, |
| 112 | 112 |
Remove: rm, |
| 113 | 113 |
ForceRemove: forceRm, |
| 114 |
+ Pull: pull, |
|
| 114 | 115 |
OutOld: job.Stdout, |
| 115 | 116 |
StreamFormatter: sf, |
| 116 | 117 |
AuthConfig: authConfig, |
| ... | ... |
@@ -1156,6 +1156,7 @@ Query Parameters: |
| 1156 | 1156 |
the resulting image in case of success |
| 1157 | 1157 |
- **q** – suppress verbose build output |
| 1158 | 1158 |
- **nocache** – do not use the cache when building the image |
| 1159 |
+- **pull** - attempt to pull the image even if an older image exists locally |
|
| 1159 | 1160 |
- **rm** - remove intermediate containers after a successful build (default behavior) |
| 1160 | 1161 |
- **forcerm - always remove intermediate containers (includes rm) |
| 1161 | 1162 |
|
| ... | ... |
@@ -312,6 +312,7 @@ To kill the container, use `docker kill`. |
| 312 | 312 |
|
| 313 | 313 |
--force-rm=false Always remove intermediate containers, even after unsuccessful builds |
| 314 | 314 |
--no-cache=false Do not use cache when building the image |
| 315 |
+ --pull=false Always attempt to pull a newer version of the image |
|
| 315 | 316 |
-q, --quiet=false Suppress the verbose output generated by the containers |
| 316 | 317 |
--rm=true Remove intermediate containers after a successful build |
| 317 | 318 |
-t, --tag="" Repository name (and optionally a tag) to be applied to the resulting image in case of success |