Skip to content

Commit

Permalink
daemon: drop side effect from registerLinks()
Browse files Browse the repository at this point in the history
(*Daemon).registerLinks() calling the WriteHostConfig() method of its
container argument is a vestigial behaviour. In the distant past,
registerLinks() would persist the container links in an SQLite database
and drop the link config from the container's persisted HostConfig. This
changed in Docker v1.10 (moby#16032) which migrated away from SQLite and
began using the link config in the container's HostConfig as the
persistent source of truth. registerLinks() no longer mutates the
HostConfig at all so persisting the HostConfig to disk falls outside of
its scope of responsibilities.

Signed-off-by: Cory Snider <csnider@mirantis.com>
  • Loading branch information
corhere committed Dec 12, 2022
1 parent 0141c6d commit 388fe4a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions daemon/daemon_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,8 @@ func getUnmountOnShutdownPath(config *config.Config) string {
return filepath.Join(config.ExecRoot, "unmount-on-shutdown")
}

// registerLinks writes the links to a file.
// registerLinks registers network links between container and other containers
// with the daemon using the specification in hostConfig.
func (daemon *Daemon) registerLinks(container *container.Container, hostConfig *containertypes.HostConfig) error {
if hostConfig == nil || hostConfig.NetworkMode.IsUserDefined() {
return nil
Expand Down Expand Up @@ -1380,10 +1381,7 @@ func (daemon *Daemon) registerLinks(container *container.Container, hostConfig *
}
}

// After we load all the links into the daemon
// set them to nil on the hostconfig
_, err := container.WriteHostConfig()
return err
return nil
}

// conditionalMountOnStart is a platform specific helper function during the
Expand Down

0 comments on commit 388fe4a

Please sign in to comment.