mirror of https://github.com/docker/compose.git
Support container_name in ACI and add network alias in dns sidecar.
(Note container_name is used in several MSFT examples) Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
parent
f6e5c911ce
commit
010c4be6b2
|
@ -120,8 +120,8 @@ func ToContainerGroup(ctx context.Context, aciContext store.AciContext, p types.
|
|||
DNSNameLabel: dnsLabelName,
|
||||
}
|
||||
}
|
||||
if len(ctnrs) > 1 {
|
||||
dnsSideCar := getDNSSidecar(ctnrs)
|
||||
if len(project.Services) > 1 {
|
||||
dnsSideCar := getDNSSidecar(project.Services)
|
||||
ctnrs = append(ctnrs, dnsSideCar)
|
||||
}
|
||||
groupDefinition.ContainerGroupProperties.Containers = &ctnrs
|
||||
|
@ -137,10 +137,13 @@ func durationToSeconds(d *types.Duration) *int32 {
|
|||
return &v
|
||||
}
|
||||
|
||||
func getDNSSidecar(containers []containerinstance.Container) containerinstance.Container {
|
||||
func getDNSSidecar(services types.Services) containerinstance.Container {
|
||||
names := []string{"/hosts"}
|
||||
for _, container := range containers {
|
||||
names = append(names, *container.Name)
|
||||
for _, service := range services {
|
||||
names = append(names, service.Name)
|
||||
if service.ContainerName != "" {
|
||||
names = append(names, service.ContainerName)
|
||||
}
|
||||
}
|
||||
dnsSideCar := containerinstance.Container{
|
||||
Name: to.StringPtr(ComposeDNSSidecarName),
|
||||
|
@ -182,8 +185,13 @@ func (s serviceConfigAciHelper) getAciContainer() (containerinstance.Container,
|
|||
return containerinstance.Container{}, err
|
||||
}
|
||||
|
||||
containerName := s.Name
|
||||
if s.ContainerName != "" {
|
||||
containerName = s.ContainerName
|
||||
}
|
||||
|
||||
return containerinstance.Container{
|
||||
Name: to.StringPtr(s.Name),
|
||||
Name: to.StringPtr(containerName),
|
||||
ContainerProperties: &containerinstance.ContainerProperties{
|
||||
Image: to.StringPtr(s.Image),
|
||||
Command: to.StringSlicePtr(s.Command),
|
||||
|
|
|
@ -15,4 +15,5 @@ services:
|
|||
- 9090:80
|
||||
|
||||
volumes:
|
||||
staticVol:
|
||||
staticVol:
|
||||
name: myVolume
|
|
@ -3,7 +3,8 @@ services:
|
|||
build: aci-demo/db
|
||||
image: gtardif/sentences-db
|
||||
|
||||
words:
|
||||
service1:
|
||||
container_name: words
|
||||
build: aci-demo/words
|
||||
image: gtardif/sentences-api
|
||||
ports:
|
||||
|
|
Loading…
Reference in New Issue