mirror of
https://github.com/docker/compose.git
synced 2025-07-13 16:54:25 +02:00
Merge pull request #9523 from laurazard/add-links-container-create
Add links to container create request.
This commit is contained in:
commit
c64dbbca6c
@ -355,6 +355,11 @@ func (s *composeService) getCreateOptions(ctx context.Context, p *types.Project,
|
|||||||
volumesFrom = append(volumesFrom, v[len("container:"):])
|
volumesFrom = append(volumesFrom, v[len("container:"):])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
links, err := s.getLinks(ctx, p.Name, service, number)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
securityOpts, err := parseSecurityOpts(p, service.SecurityOpt)
|
securityOpts, err := parseSecurityOpts(p, service.SecurityOpt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
@ -389,6 +394,7 @@ func (s *composeService) getCreateOptions(ctx context.Context, p *types.Project,
|
|||||||
Runtime: service.Runtime,
|
Runtime: service.Runtime,
|
||||||
LogConfig: logConfig,
|
LogConfig: logConfig,
|
||||||
GroupAdd: service.GroupAdd,
|
GroupAdd: service.GroupAdd,
|
||||||
|
Links: links,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &containerConfig, &hostConfig, networkConfig, nil
|
return &containerConfig, &hostConfig, networkConfig, nil
|
||||||
|
9
pkg/e2e/fixtures/network-links/compose.yaml
Normal file
9
pkg/e2e/fixtures/network-links/compose.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
services:
|
||||||
|
container1:
|
||||||
|
image: nginx
|
||||||
|
network_mode: bridge
|
||||||
|
container2:
|
||||||
|
image: nginx
|
||||||
|
network_mode: bridge
|
||||||
|
links:
|
||||||
|
- container1
|
@ -69,7 +69,7 @@ func TestNetworks(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNetworkAliassesAndLinks(t *testing.T) {
|
func TestNetworkAliasses(t *testing.T) {
|
||||||
c := NewParallelE2eCLI(t, binDir)
|
c := NewParallelE2eCLI(t, binDir)
|
||||||
|
|
||||||
const projectName = "network_alias_e2e"
|
const projectName = "network_alias_e2e"
|
||||||
@ -93,6 +93,25 @@ func TestNetworkAliassesAndLinks(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNetworkLinks(t *testing.T) {
|
||||||
|
c := NewParallelE2eCLI(t, binDir)
|
||||||
|
|
||||||
|
const projectName = "network_link_e2e"
|
||||||
|
|
||||||
|
t.Run("up", func(t *testing.T) {
|
||||||
|
c.RunDockerComposeCmd("-f", "./fixtures/network-links/compose.yaml", "--project-name", projectName, "up", "-d")
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("curl links in default bridge network", func(t *testing.T) {
|
||||||
|
res := c.RunDockerComposeCmd("-f", "./fixtures/network-links/compose.yaml", "--project-name", projectName, "exec", "-T", "container2", "curl", "http://container1/")
|
||||||
|
assert.Assert(t, strings.Contains(res.Stdout(), "Welcome to nginx!"), res.Stdout())
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("down", func(t *testing.T) {
|
||||||
|
_ = c.RunDockerComposeCmd("--project-name", projectName, "down")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestIPAMConfig(t *testing.T) {
|
func TestIPAMConfig(t *testing.T) {
|
||||||
c := NewParallelE2eCLI(t, binDir)
|
c := NewParallelE2eCLI(t, binDir)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user