mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Ensure data-race-free access to the daemon configuration without locking by mutating a deep copy of the config and atomically storing a pointer to the copy into the daemon-wide configStore value. Any operations which need to read from the daemon config must capture the configStore value only once and pass it around to guarantee a consistent view of the config. Signed-off-by: Cory Snider <csnider@mirantis.com>
25 lines
797 B
Go
25 lines
797 B
Go
//go:build !windows
|
|
|
|
package daemon // import "github.com/docker/docker/daemon"
|
|
|
|
import (
|
|
"github.com/docker/docker/container"
|
|
"github.com/docker/docker/daemon/config"
|
|
)
|
|
|
|
// getLibcontainerdCreateOptions callers must hold a lock on the container
|
|
func (daemon *Daemon) getLibcontainerdCreateOptions(daemonCfg *config.Config, container *container.Container) (string, interface{}, error) {
|
|
// Ensure a runtime has been assigned to this container
|
|
if container.HostConfig.Runtime == "" {
|
|
container.HostConfig.Runtime = daemonCfg.DefaultRuntime
|
|
container.CheckpointTo(daemon.containersReplica)
|
|
}
|
|
|
|
binary, opts, err := daemon.getRuntime(daemonCfg, container.HostConfig.Runtime)
|
|
if err != nil {
|
|
return "", nil, setExitCodeFromError(container.SetExitCode, err)
|
|
}
|
|
|
|
return binary, opts, nil
|
|
}
|