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

Commit 96be897

Browse files
committed
Fix: no connect & start if not recreated
Signed-off-by: xi.han <[email protected]>
1 parent 57bd716 commit 96be897

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

docker/service/service.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,19 +327,21 @@ func (s *Service) up(ctx context.Context, imageName string, create bool, options
327327

328328
return s.eachContainer(ctx, containers, func(c *container.Container) error {
329329
var err error
330+
oldID := c.ID()
330331
if create {
331332
c, err = s.recreateIfNeeded(ctx, c, options.NoRecreate, options.ForceRecreate)
332333
if err != nil {
333334
return err
334335
}
335336
}
336337

337-
if err := s.connectContainerToNetworks(ctx, c, false); err != nil {
338-
return err
338+
if c.ID() != oldID {
339+
if err := s.connectContainerToNetworks(ctx, c, false); err != nil {
340+
return err
341+
}
339342
}
340343

341344
err = c.Start(ctx)
342-
343345
if err == nil {
344346
s.project.Notify(events.ContainerStarted, s.name, map[string]string{
345347
"name": c.Name(),

0 commit comments

Comments
 (0)