mirror of
https://github.com/docker/compose.git
synced 2025-07-21 04:34:38 +02:00
don't create from run command during dependencies creation process
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
parent
c97e40e2b8
commit
149b882ebf
@ -176,18 +176,22 @@ func applyRunOptions(project *types.Project, service *types.ServiceConfig, opts
|
||||
}
|
||||
|
||||
func (s *composeService) startDependencies(ctx context.Context, project *types.Project, options api.RunOptions) error {
|
||||
var dependencies []string
|
||||
for name := range project.Services {
|
||||
dependencies := types.Services{}
|
||||
var requestedService types.ServiceConfig
|
||||
for name, service := range project.Services {
|
||||
if name != options.Service {
|
||||
dependencies = append(dependencies, name)
|
||||
dependencies[name] = service
|
||||
} else {
|
||||
requestedService = service
|
||||
}
|
||||
}
|
||||
|
||||
project, err := project.WithSelectedServices(dependencies)
|
||||
if err != nil {
|
||||
return err
|
||||
if len(dependencies) > 0 {
|
||||
project.Services = dependencies
|
||||
project.DisabledServices[options.Service] = requestedService
|
||||
}
|
||||
err = s.Create(ctx, project, api.CreateOptions{
|
||||
|
||||
err := s.Create(ctx, project, api.CreateOptions{
|
||||
Build: options.Build,
|
||||
IgnoreOrphans: options.IgnoreOrphans,
|
||||
RemoveOrphans: options.RemoveOrphans,
|
||||
|
@ -196,4 +196,18 @@ func TestLocalComposeRun(t *testing.T) {
|
||||
"front", "env")
|
||||
res.Assert(t, icmd.Expected{Out: "FOO=BAR"})
|
||||
})
|
||||
|
||||
t.Run("compose run -rm with stop signal", func(t *testing.T) {
|
||||
projectName := "run-test"
|
||||
res := c.RunDockerComposeCmd(t, "--project-name", projectName, "-f", "./fixtures/ps-test/compose.yaml", "run", "--rm", "-d", "nginx")
|
||||
res.Assert(t, icmd.Success)
|
||||
|
||||
res = c.RunDockerCmd(t, "ps", "--quiet", "--filter", "name=run-test-nginx")
|
||||
containerID := strings.TrimSpace(res.Stdout())
|
||||
|
||||
res = c.RunDockerCmd(t, "stop", containerID)
|
||||
res.Assert(t, icmd.Success)
|
||||
res = c.RunDockerCmd(t, "ps", "--all", "--filter", "name=run-test-nginx", "--format", "'{{.Names}}'")
|
||||
assert.Assert(t, !strings.Contains(res.Stdout(), "run-test-nginx"), res.Stdout())
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user