@@ -30,6 +30,7 @@ import (
3030type createOptions struct {
3131 Build bool
3232 noBuild bool
33+ Pull string
3334 removeOrphans bool
3435 ignoreOrphans bool
3536 forceRecreate bool
@@ -56,6 +57,7 @@ func createCommand(p *projectOptions, backend api.Service) *cobra.Command {
5657 return nil
5758 }),
5859 RunE : p .WithProject (func (ctx context.Context , project * types.Project ) error {
60+ opts .Apply (project )
5961 return backend .Create (ctx , project , api.CreateOptions {
6062 RemoveOrphans : opts .removeOrphans ,
6163 IgnoreOrphans : opts .ignoreOrphans ,
@@ -71,6 +73,7 @@ func createCommand(p *projectOptions, backend api.Service) *cobra.Command {
7173 flags := cmd .Flags ()
7274 flags .BoolVar (& opts .Build , "build" , false , "Build images before starting containers." )
7375 flags .BoolVar (& opts .noBuild , "no-build" , false , "Don't build an image, even if it's missing." )
76+ flags .StringVar (& opts .Pull , "pull" , "missing" , `Pull image before running ("always"|"missing"|"never")` )
7477 flags .BoolVar (& opts .forceRecreate , "force-recreate" , false , "Recreate containers even if their configuration and image haven't changed." )
7578 flags .BoolVar (& opts .noRecreate , "no-recreate" , false , "If containers already exist, don't recreate them. Incompatible with --force-recreate." )
7679 return cmd
@@ -105,6 +108,12 @@ func (opts createOptions) GetTimeout() *time.Duration {
105108}
106109
107110func (opts createOptions ) Apply (project * types.Project ) {
111+ if opts .Pull != "" {
112+ for i , service := range project .Services {
113+ service .PullPolicy = opts .Pull
114+ project .Services [i ] = service
115+ }
116+ }
108117 if opts .Build {
109118 for i , service := range project .Services {
110119 if service .Build == nil {
0 commit comments