Skip to content

Commit c47079e

Browse files
committed
don't apply default pull policy from command line if one is define in service configuration
Signed-off-by: Guillaume Lours <[email protected]>
1 parent bf4ca62 commit c47079e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cmd/compose/create.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type createOptions struct {
3131
Build bool
3232
noBuild bool
3333
Pull string
34+
pullChanged bool
3435
removeOrphans bool
3536
ignoreOrphans bool
3637
forceRecreate bool
@@ -47,7 +48,8 @@ func createCommand(p *projectOptions, backend api.Service) *cobra.Command {
4748
cmd := &cobra.Command{
4849
Use: "create [OPTIONS] [SERVICE...]",
4950
Short: "Creates containers for a service.",
50-
PreRunE: Adapt(func(ctx context.Context, args []string) error {
51+
PreRunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error {
52+
opts.pullChanged = cmd.Flags().Changed("pull")
5153
if opts.Build && opts.noBuild {
5254
return fmt.Errorf("--build and --no-build are incompatible")
5355
}
@@ -108,7 +110,7 @@ func (opts createOptions) GetTimeout() *time.Duration {
108110
}
109111

110112
func (opts createOptions) Apply(project *types.Project) {
111-
if opts.Pull != "" {
113+
if opts.pullChanged {
112114
for i, service := range project.Services {
113115
service.PullPolicy = opts.Pull
114116
project.Services[i] = service

0 commit comments

Comments
 (0)