Skip to content

Commit cf7319f

Browse files
ulyssessouzandeloof
authored andcommitted
Only kill running containers
Signed-off-by: Ulysses Souza <[email protected]>
1 parent 740276f commit cf7319f

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

cmd/compatibility/convert.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func getStringFlags() []string {
4343
}
4444
}
4545

46+
// Convert transforms standalone docker-compose args into CLI plugin compliant ones
4647
func Convert(args []string) []string {
4748
var rootFlags []string
4849
command := []string{compose.PluginName}

pkg/compose/kill.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (s *composeService) kill(ctx context.Context, project *types.Project, optio
4242
}
4343

4444
var containers Containers
45-
containers, err := s.getContainers(ctx, project.Name, oneOffInclude, true, services...)
45+
containers, err := s.getContainers(ctx, project.Name, oneOffInclude, false, services...)
4646
if err != nil {
4747
return err
4848
}

pkg/compose/kill_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ func TestKillAll(t *testing.T) {
4545
project := types.Project{Name: strings.ToLower(testProject), Services: []types.ServiceConfig{testService("service1"), testService("service2")}}
4646

4747
ctx := context.Background()
48-
api.EXPECT().ContainerList(ctx, projectFilterListOpt()).Return(
48+
api.EXPECT().ContainerList(ctx, moby.ContainerListOptions{
49+
Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject))),
50+
}).Return(
4951
[]moby.Container{testContainer("service1", "123", false), testContainer("service1", "456", false), testContainer("service2", "789", false)}, nil)
5052
api.EXPECT().ContainerKill(anyCancellableContext(), "123", "").Return(nil)
5153
api.EXPECT().ContainerKill(anyCancellableContext(), "456", "").Return(nil)
@@ -64,9 +66,7 @@ func TestKillSignal(t *testing.T) {
6466

6567
project := types.Project{Name: strings.ToLower(testProject), Services: []types.ServiceConfig{testService(serviceName)}}
6668
listOptions := moby.ContainerListOptions{
67-
Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)),
68-
serviceFilter(serviceName)),
69-
All: true,
69+
Filters: filters.NewArgs(projectFilter(strings.ToLower(testProject)), serviceFilter(serviceName)),
7070
}
7171

7272
ctx := context.Background()

0 commit comments

Comments
 (0)