mirror of https://github.com/docker/compose.git
Only start direct dependencies of service on `compose run ...`
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
This commit is contained in:
parent
8862f95858
commit
80b7a8d274
|
@ -262,7 +262,9 @@ func startDependencies(ctx context.Context, backend api.Service, project types.P
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(dependencies) > 0 {
|
if len(dependencies) > 0 {
|
||||||
return backend.Start(ctx, project.Name, api.StartOptions{})
|
return backend.Start(ctx, project.Name, api.StartOptions{
|
||||||
|
Project: &project,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,4 +117,16 @@ func TestLocalComposeRun(t *testing.T) {
|
||||||
res := c.RunDockerCmd("ps", "--all")
|
res := c.RunDockerCmd("ps", "--all")
|
||||||
assert.Assert(t, !strings.Contains(res.Stdout(), "run-test"), res.Stdout())
|
assert.Assert(t, !strings.Contains(res.Stdout(), "run-test"), res.Stdout())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("run starts only container and dependencies", func(t *testing.T) {
|
||||||
|
// ensure that even if another service is up run does not start it: https://github.com/docker/compose/issues/9459
|
||||||
|
res := c.RunDockerComposeCmd("-f", "./fixtures/run-test/deps.yaml", "up", "service_b")
|
||||||
|
res.Assert(t, icmd.Success)
|
||||||
|
|
||||||
|
res = c.RunDockerComposeCmd("-f", "./fixtures/run-test/deps.yaml", "run", "service_a")
|
||||||
|
assert.Assert(t, strings.Contains(res.Combined(), "shared_dep"), res.Combined())
|
||||||
|
assert.Assert(t, !strings.Contains(res.Combined(), "service_b"), res.Combined())
|
||||||
|
|
||||||
|
c.RunDockerComposeCmd("-f", "./fixtures/run-test/deps.yaml", "down", "--remove-orphans")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
version: "3.6"
|
||||||
|
services:
|
||||||
|
service_a:
|
||||||
|
image: bash
|
||||||
|
command: echo "a"
|
||||||
|
depends_on:
|
||||||
|
- shared_dep
|
||||||
|
service_b:
|
||||||
|
image: bash
|
||||||
|
command: echo "b"
|
||||||
|
depends_on:
|
||||||
|
- shared_dep
|
||||||
|
shared_dep:
|
||||||
|
image: bash
|
Loading…
Reference in New Issue