Skip to content

Commit 10e0732

Browse files
committed
don't create from run command during dependencies creation process
Signed-off-by: Guillaume Lours <[email protected]>
1 parent 22e23bd commit 10e0732

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

pkg/compose/run.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,22 @@ func applyRunOptions(project *types.Project, service *types.ServiceConfig, opts
177177

178178
func (s *composeService) startDependencies(ctx context.Context, project *types.Project, options api.RunOptions) error {
179179
var dependencies []string
180-
for name := range project.Services {
180+
var requestedService types.ServiceConfig
181+
for name, svc := range project.Services {
181182
if name != options.Service {
182183
dependencies = append(dependencies, name)
184+
} else {
185+
requestedService = svc
183186
}
184187
}
185188

186189
project, err := project.WithSelectedServices(dependencies)
187190
if err != nil {
188191
return err
189192
}
193+
project.DisabledServices[options.Service] = requestedService
194+
delete(project.Services, options.Service)
195+
190196
err = s.Create(ctx, project, api.CreateOptions{
191197
Build: options.Build,
192198
IgnoreOrphans: options.IgnoreOrphans,

pkg/e2e/compose_run_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,18 @@ func TestLocalComposeRun(t *testing.T) {
196196
"front", "env")
197197
res.Assert(t, icmd.Expected{Out: "FOO=BAR"})
198198
})
199+
200+
t.Run("compose run -rm with stop signal", func(t *testing.T) {
201+
projectName := "run-test"
202+
res := c.RunDockerComposeCmd(t, "--project-name", projectName, "-f", "./fixtures/ps-test/compose.yaml", "run", "--rm", "-d", "nginx")
203+
res.Assert(t, icmd.Success)
204+
205+
res = c.RunDockerCmd(t, "ps", "--quiet")
206+
containerID := strings.TrimSpace(res.Stdout())
207+
208+
res = c.RunDockerCmd(t, "stop", containerID)
209+
res.Assert(t, icmd.Success)
210+
res = c.RunDockerCmd(t, "ps", "--all")
211+
assert.Assert(t, !strings.Contains(res.Stdout(), "run-test-nginx"), res.Stdout())
212+
})
199213
}

0 commit comments

Comments
 (0)