|  | @@ -57,7 +57,7 @@ func (s *composeService) ensureScale(ctx context.Context, actual []moby.Containe
 | 
	
		
			
				|  |  |  		missing := scale - len(actual)
 | 
	
		
			
				|  |  |  		for i := 0; i < missing; i++ {
 | 
	
		
			
				|  |  |  			number := next + i
 | 
	
		
			
				|  |  | -			name := getContainerLogPrefix(project.Name, service, number)
 | 
	
		
			
				|  |  | +			name := getContainerName(project.Name, service, number)
 | 
	
		
			
				|  |  |  			eg.Go(func() error {
 | 
	
		
			
				|  |  |  				return s.createContainer(ctx, project, service, name, number, false)
 | 
	
		
			
				|  |  |  			})
 | 
	
	
		
			
				|  | @@ -109,7 +109,7 @@ func (s *composeService) ensureService(ctx context.Context, observedState Contai
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	for _, container := range actual {
 | 
	
		
			
				|  |  |  		container := container
 | 
	
		
			
				|  |  | -		name := getContainerName(container)
 | 
	
		
			
				|  |  | +		name := getCanonicalContainerName(container)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		diverged := container.Labels[configHashLabel] != expected
 | 
	
		
			
				|  |  |  		if diverged || service.Extensions[extLifecycle] == forceRecreate {
 | 
	
	
		
			
				|  | @@ -135,7 +135,7 @@ func (s *composeService) ensureService(ctx context.Context, observedState Contai
 | 
	
		
			
				|  |  |  	return eg.Wait()
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -func getContainerLogPrefix(projectName string, service types.ServiceConfig, number int) string {
 | 
	
		
			
				|  |  | +func getContainerName(projectName string, service types.ServiceConfig, number int) string {
 | 
	
		
			
				|  |  |  	name := fmt.Sprintf("%s_%s_%d", projectName, service.Name, number)
 | 
	
		
			
				|  |  |  	if service.ContainerName != "" {
 | 
	
		
			
				|  |  |  		name = service.ContainerName
 | 
	
	
		
			
				|  | @@ -218,12 +218,12 @@ func (s *composeService) createContainer(ctx context.Context, project *types.Pro
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  func (s *composeService) recreateContainer(ctx context.Context, project *types.Project, service types.ServiceConfig, container moby.Container) error {
 | 
	
		
			
				|  |  |  	w := progress.ContextWriter(ctx)
 | 
	
		
			
				|  |  | -	w.Event(progress.NewEvent(getContainerName(container), progress.Working, "Recreate"))
 | 
	
		
			
				|  |  | +	w.Event(progress.NewEvent(getCanonicalContainerName(container), progress.Working, "Recreate"))
 | 
	
		
			
				|  |  |  	err := s.apiClient.ContainerStop(ctx, container.ID, nil)
 | 
	
		
			
				|  |  |  	if err != nil {
 | 
	
		
			
				|  |  |  		return err
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -	name := getContainerName(container)
 | 
	
		
			
				|  |  | +	name := getCanonicalContainerName(container)
 | 
	
		
			
				|  |  |  	tmpName := fmt.Sprintf("%s_%s", container.ID[:12], name)
 | 
	
		
			
				|  |  |  	err = s.apiClient.ContainerRename(ctx, container.ID, tmpName)
 | 
	
		
			
				|  |  |  	if err != nil {
 | 
	
	
		
			
				|  | @@ -241,7 +241,7 @@ func (s *composeService) recreateContainer(ctx context.Context, project *types.P
 | 
	
		
			
				|  |  |  	if err != nil {
 | 
	
		
			
				|  |  |  		return err
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -	w.Event(progress.NewEvent(getContainerName(container), progress.Done, "Recreated"))
 | 
	
		
			
				|  |  | +	w.Event(progress.NewEvent(getCanonicalContainerName(container), progress.Done, "Recreated"))
 | 
	
		
			
				|  |  |  	setDependentLifecycle(project, service.Name, forceRecreate)
 | 
	
		
			
				|  |  |  	return nil
 | 
	
		
			
				|  |  |  }
 | 
	
	
		
			
				|  | @@ -261,12 +261,12 @@ func setDependentLifecycle(project *types.Project, service string, strategy stri
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  func (s *composeService) restartContainer(ctx context.Context, container moby.Container) error {
 | 
	
		
			
				|  |  |  	w := progress.ContextWriter(ctx)
 | 
	
		
			
				|  |  | -	w.Event(progress.NewEvent(getContainerName(container), progress.Working, "Restart"))
 | 
	
		
			
				|  |  | +	w.Event(progress.NewEvent(getCanonicalContainerName(container), progress.Working, "Restart"))
 | 
	
		
			
				|  |  |  	err := s.apiClient.ContainerStart(ctx, container.ID, moby.ContainerStartOptions{})
 | 
	
		
			
				|  |  |  	if err != nil {
 | 
	
		
			
				|  |  |  		return err
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -	w.Event(progress.NewEvent(getContainerName(container), progress.Done, "Restarted"))
 | 
	
		
			
				|  |  | +	w.Event(progress.NewEvent(getCanonicalContainerName(container), progress.Done, "Restarted"))
 | 
	
		
			
				|  |  |  	return nil
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -281,8 +281,8 @@ func (s *composeService) createMobyContainer(ctx context.Context, project *types
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	id := created.ID
 | 
	
		
			
				|  |  |  	for netName := range service.Networks {
 | 
	
		
			
				|  |  | -		network := project.Networks[netName]
 | 
	
		
			
				|  |  | -		err = s.connectContainerToNetwork(ctx, id, service.Name, network.Name)
 | 
	
		
			
				|  |  | +		netwrk := project.Networks[netName]
 | 
	
		
			
				|  |  | +		err = s.connectContainerToNetwork(ctx, id, netwrk.Name, service.Name, getContainerName(project.Name, service, number))
 | 
	
		
			
				|  |  |  		if err != nil {
 | 
	
		
			
				|  |  |  			return err
 | 
	
		
			
				|  |  |  		}
 | 
	
	
		
			
				|  | @@ -290,9 +290,9 @@ func (s *composeService) createMobyContainer(ctx context.Context, project *types
 | 
	
		
			
				|  |  |  	return nil
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -func (s *composeService) connectContainerToNetwork(ctx context.Context, id string, service string, n string) error {
 | 
	
		
			
				|  |  | -	err := s.apiClient.NetworkConnect(ctx, n, id, &network.EndpointSettings{
 | 
	
		
			
				|  |  | -		Aliases: []string{service},
 | 
	
		
			
				|  |  | +func (s *composeService) connectContainerToNetwork(ctx context.Context, id string, netwrk string, aliases ...string) error {
 | 
	
		
			
				|  |  | +	err := s.apiClient.NetworkConnect(ctx, netwrk, id, &network.EndpointSettings{
 | 
	
		
			
				|  |  | +		Aliases: aliases,
 | 
	
		
			
				|  |  |  	})
 | 
	
		
			
				|  |  |  	if err != nil {
 | 
	
		
			
				|  |  |  		return err
 | 
	
	
		
			
				|  | @@ -352,10 +352,10 @@ func (s *composeService) startService(ctx context.Context, project *types.Projec
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		eg.Go(func() error {
 | 
	
		
			
				|  |  |  			w := progress.ContextWriter(ctx)
 | 
	
		
			
				|  |  | -			w.Event(progress.StartingEvent(getContainerName(container)))
 | 
	
		
			
				|  |  | +			w.Event(progress.StartingEvent(getCanonicalContainerName(container)))
 | 
	
		
			
				|  |  |  			err := s.apiClient.ContainerStart(ctx, container.ID, moby.ContainerStartOptions{})
 | 
	
		
			
				|  |  |  			if err == nil {
 | 
	
		
			
				|  |  | -				w.Event(progress.StartedEvent(getContainerName(container)))
 | 
	
		
			
				|  |  | +				w.Event(progress.StartedEvent(getCanonicalContainerName(container)))
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			return err
 | 
	
		
			
				|  |  |  		})
 |