treat a network supplier as an implicit link

This commit is contained in:
nils måsén 2023-08-08 18:22:57 +02:00
parent e97671f293
commit fdd0406fd4
2 changed files with 8 additions and 1 deletions

View file

@ -4,4 +4,4 @@ For example, imagine you were running a _mysql_ container and a _wordpress_ cont
If you want to override existing links, or if you are not using links, you can use special `com.centurylinklabs.watchtower.depends-on` label with dependent container names, separated by a comma. If you want to override existing links, or if you are not using links, you can use special `com.centurylinklabs.watchtower.depends-on` label with dependent container names, separated by a comma.
When you have a depending container that is using `network_mode: service:container` then links or the `depends-on` label is required for the restart of the depending container to work. When you have a depending container that is using `network_mode: service:container` then watchtower will treat that container as an implicit link.

View file

@ -196,6 +196,13 @@ func (c Container) Links() []string {
name := strings.Split(link, ":")[0] name := strings.Split(link, ":")[0]
links = append(links, name) links = append(links, name)
} }
// If the container uses another container for networking, it can be considered an implicit link
// since the container would stop working if the network supplier were to be recreated
networkMode := c.containerInfo.HostConfig.NetworkMode
if networkMode.IsContainer() {
links = append(links, networkMode.ConnectedContainer())
}
} }
return links return links