mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-16 23:20:12 +01:00
Change NetworkMode container:ID to container:NAME if network_mode: service:container is set
This commit is contained in:
parent
bbc81c4cee
commit
d1bb4da50c
1 changed files with 9 additions and 0 deletions
|
|
@ -157,6 +157,15 @@ func (client dockerClient) GetContainer(containerID t.ContainerID) (t.Container,
|
|||
return &Container{}, err
|
||||
}
|
||||
|
||||
containerNetworkMode := strings.Split(string(containerInfo.HostConfig.NetworkMode), ":")
|
||||
if len(containerNetworkMode) == 2 {
|
||||
parentContainer, err := client.api.ContainerInspect(bg, containerNetworkMode[1])
|
||||
if err != nil {
|
||||
log.Debug("Unable to fetch parentContainer.")
|
||||
}
|
||||
containerInfo.HostConfig.NetworkMode = container.NetworkMode(fmt.Sprintf("container:%s", parentContainer.Name))
|
||||
}
|
||||
|
||||
imageInfo, _, err := client.api.ImageInspectWithRaw(bg, containerInfo.Image)
|
||||
if err != nil {
|
||||
log.Warnf("Failed to retrieve container image info: %v", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue