diff --git a/docs/linked-containers.md b/docs/linked-containers.md index d272367..c7e9be8 100644 --- a/docs/linked-containers.md +++ b/docs/linked-containers.md @@ -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. -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. \ No newline at end of file +When you have a depending container that is using `network_mode: service:container` then watchtower will treat that container as an implicit link. diff --git a/pkg/container/container.go b/pkg/container/container.go index 20ae2e0..0f78f62 100644 --- a/pkg/container/container.go +++ b/pkg/container/container.go @@ -196,6 +196,13 @@ func (c Container) Links() []string { name := strings.Split(link, ":")[0] 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