don't try to start dependencies when there are none

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2022-03-07 08:09:20 +01:00
parent fcff39631a
commit dbe7de50a7
2 changed files with 9 additions and 4 deletions

View File

@ -245,10 +245,15 @@ func startDependencies(ctx context.Context, backend api.Service, project types.P
project.Services = dependencies
project.DisabledServices = append(project.DisabledServices, requestedService)
if err := backend.Create(ctx, &project, api.CreateOptions{
err := backend.Create(ctx, &project, api.CreateOptions{
IgnoreOrphans: ignoreOrphans,
}); err != nil {
})
if err != nil {
return err
}
return backend.Start(ctx, project.Name, api.StartOptions{})
if len(dependencies) > 0 {
return backend.Start(ctx, project.Name, api.StartOptions{})
}
return nil
}

View File

@ -100,7 +100,7 @@ func (s *composeService) projectFromName(containers Containers, projectName stri
Name: projectName,
}
if len(containers) == 0 {
return project, errors.New("no such project: " + projectName)
return project, errors.Wrap(api.ErrNotFound, fmt.Sprintf("no container found for project %q", projectName))
}
set := map[string]*types.ServiceConfig{}
for _, c := range containers {