Skip to content

Commit 9976077

Browse files
ndeloofglours
authored andcommitted
introduce --pull
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 70ccc98 commit 9976077

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

cmd/compose/create.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
type createOptions struct {
3131
Build bool
3232
noBuild bool
33+
Pull string
3334
removeOrphans bool
3435
ignoreOrphans bool
3536
forceRecreate bool
@@ -71,6 +72,7 @@ func createCommand(p *projectOptions, backend api.Service) *cobra.Command {
7172
flags := cmd.Flags()
7273
flags.BoolVar(&opts.Build, "build", false, "Build images before starting containers.")
7374
flags.BoolVar(&opts.noBuild, "no-build", false, "Don't build an image, even if it's missing.")
75+
flags.StringVar(&opts.Pull, "pull", "missing", `Pull image before running ("always"|"missing"|"never")`)
7476
flags.BoolVar(&opts.forceRecreate, "force-recreate", false, "Recreate containers even if their configuration and image haven't changed.")
7577
flags.BoolVar(&opts.noRecreate, "no-recreate", false, "If containers already exist, don't recreate them. Incompatible with --force-recreate.")
7678
return cmd
@@ -105,6 +107,12 @@ func (opts createOptions) GetTimeout() *time.Duration {
105107
}
106108

107109
func (opts createOptions) Apply(project *types.Project) {
110+
if opts.Pull != "" {
111+
for i, service := range project.Services {
112+
service.PullPolicy = opts.Pull
113+
project.Services[i] = service
114+
}
115+
}
108116
if opts.Build {
109117
for i, service := range project.Services {
110118
if service.Build == nil {

cmd/compose/up.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func upCommand(p *projectOptions, backend api.Service) *cobra.Command {
115115
flags.BoolVarP(&up.Detach, "detach", "d", false, "Detached mode: Run containers in the background")
116116
flags.BoolVar(&create.Build, "build", false, "Build images before starting containers.")
117117
flags.BoolVar(&create.noBuild, "no-build", false, "Don't build an image, even if it's missing.")
118+
flags.StringVar(&create.Pull, "pull", "missing", `Pull image before running ("always"|"missing"|"never")`)
118119
flags.BoolVar(&create.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.")
119120
flags.StringArrayVar(&up.scale, "scale", []string{}, "Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.")
120121
flags.BoolVar(&up.noColor, "no-color", false, "Produce monochrome output.")

0 commit comments

Comments
 (0)