Merge pull request #9504 from docker/nicksieger/9427

fix: bring up services with deps with --no-deps
This commit is contained in:
Guillaume Lours 2022-05-31 23:39:19 +02:00 committed by GitHub
commit 335decceda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View File

@ -183,7 +183,11 @@ func prepareServicesDependsOn(p *types.Project) error {
if service.DependsOn == nil {
service.DependsOn = make(types.DependsOnConfig)
}
deps, err := p.GetServices(dependencies...)
// Verify dependencies exist in the project, whether disabled or not
projAllServices := types.Project{}
projAllServices.Services = p.AllServices()
deps, err := projAllServices.GetServices(dependencies...)
if err != nil {
return err
}

View File

@ -0,0 +1,8 @@
services:
foo:
image: nginx:alpine
links:
- bar
bar:
image: nginx:alpine

View File

@ -131,6 +131,13 @@ func TestStartStopWithDependencies(t *testing.T) {
assert.Assert(t, strings.Contains(res.Combined(), "e2e-start-stop-with-dependencies-foo-1"), res.Combined())
})
t.Run("Up no-deps links", func(t *testing.T) {
_ = c.RunDockerComposeCmd("--project-name", projectName, "down")
res := c.RunDockerComposeCmd("-f", "./fixtures/links/compose.yaml", "--project-name", projectName, "up", "--no-deps", "-d", "foo")
assert.Assert(t, strings.Contains(res.Combined(), "Container e2e-start-stop-with-dependencies-foo-1 Started"), res.Combined())
assert.Assert(t, !strings.Contains(res.Combined(), "Container e2e-start-stop-with-dependencies-bar-1 Started"), res.Combined())
})
t.Run("down", func(t *testing.T) {
_ = c.RunDockerComposeCmd("--project-name", projectName, "down")
})