Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 8774bac

Browse files
committed
Merge pull request #135 from vdemeester/complete-create-flags
Add flags for create command
2 parents 1821143 + ef115cc commit 8774bac

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

cli/command/command.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ func CreateCommand(factory app.ProjectFactory) cli.Command {
1414
Name: "create",
1515
Usage: "Create all services but do not start",
1616
Action: app.WithProject(factory, app.ProjectCreate),
17+
Flags: []cli.Flag{
18+
cli.BoolFlag{
19+
Name: "no-recreate",
20+
Usage: "If containers already exist, don't recreate them. Incompatible with --force-recreate.",
21+
},
22+
cli.BoolFlag{
23+
Name: "force-recreate",
24+
Usage: "Recreate containers even if their configuration and image haven't changed. Incompatible with --no-recreate.",
25+
},
26+
},
1727
}
1828
}
1929

@@ -269,7 +279,7 @@ func Populate(context *project.Context, c *cli.Context) {
269279

270280
if c.Command.Name == "logs" {
271281
context.Log = true
272-
} else if c.Command.Name == "up" {
282+
} else if c.Command.Name == "up" || c.Command.Name == "create" {
273283
context.Log = !c.Bool("d")
274284
context.NoRecreate = c.Bool("no-recreate")
275285
context.ForceRecreate = c.Bool("force-recreate")

docker/service.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,22 @@ func (s *Service) DependentServices() []project.ServiceRelationship {
4141

4242
// Create implements Service.Create.
4343
func (s *Service) Create() error {
44+
containers, err := s.collectContainers()
45+
if err != nil {
46+
return err
47+
}
48+
4449
imageName, err := s.build()
4550
if err != nil {
4651
return err
4752
}
4853

54+
if len(containers) != 0 {
55+
return s.eachContainer(func(c *Container) error {
56+
return s.recreateIfNeeded(imageName, c)
57+
})
58+
}
59+
4960
_, err = s.createOne(imageName)
5061
return err
5162
}

0 commit comments

Comments
 (0)