Merge pull request #1300 from docker/start_recreate

introduce create --force-recreate and --no-recreate
This commit is contained in:
Nicolas De loof 2021-02-15 10:50:33 +01:00 committed by GitHub
commit d6c20045f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -22,6 +22,8 @@ import (
type createOptions struct { type createOptions struct {
*composeOptions *composeOptions
forceRecreate bool
noRecreate bool
} }
func createCommand(p *projectOptions) *cobra.Command { func createCommand(p *projectOptions) *cobra.Command {
@ -37,11 +39,15 @@ func createCommand(p *projectOptions) *cobra.Command {
projectOptions: p, projectOptions: p,
Build: opts.Build, Build: opts.Build,
}, },
noStart: true, noStart: true,
forceRecreate: opts.forceRecreate,
noRecreate: opts.noRecreate,
}, args) }, args)
}, },
} }
flags := cmd.Flags() flags := cmd.Flags()
flags.BoolVar(&opts.Build, "build", false, "Build images before starting containers.") flags.BoolVar(&opts.Build, "build", false, "Build images before starting containers.")
flags.BoolVar(&opts.forceRecreate, "force-recreate", false, "Recreate containers even if their configuration and image haven't changed.")
flags.BoolVar(&opts.noRecreate, "no-recreate", false, "If containers already exist, don't recreate them. Incompatible with --force-recreate.")
return cmd return cmd
} }