New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow switching Windows runtimes. #42089
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ import ( | |
containertypes "github.com/docker/docker/api/types/container" | ||
"github.com/docker/docker/container" | ||
"github.com/docker/docker/daemon/config" | ||
"github.com/docker/docker/libcontainerd/local" | ||
"github.com/docker/docker/libcontainerd/remote" | ||
"github.com/docker/docker/libnetwork" | ||
nwconfig "github.com/docker/docker/libnetwork/config" | ||
"github.com/docker/docker/libnetwork/datastore" | ||
|
@@ -40,6 +42,9 @@ const ( | |
windowsMaxCPUShares = 10000 | ||
windowsMinCPUPercent = 1 | ||
windowsMaxCPUPercent = 100 | ||
|
||
windowsV1RuntimeName = "com.docker.hcsshim.v1" | ||
windowsV2RuntimeName = "io.containerd.runhcs.v1" | ||
) | ||
|
||
// Windows containers are much larger than Linux containers and each of them | ||
|
@@ -649,3 +654,42 @@ func setupResolvConf(config *config.Config) { | |
func (daemon *Daemon) RawSysInfo() *sysinfo.SysInfo { | ||
return sysinfo.New() | ||
} | ||
|
||
func (daemon *Daemon) initLibcontainerd(ctx context.Context) error { | ||
var err error | ||
|
||
rt := daemon.configStore.GetDefaultRuntimeName() | ||
if rt == "" { | ||
if daemon.configStore.ContainerdAddr == "" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No cases where we use a default value for the containerd address or anything like that? ISTR some talk about trying to default to V2 on 2022+? (I guess that ship sailed?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So my plan is to follow-up with a PR to embed containerd and use that if no address is specified on both linux and windows. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That said, even on Linux we don't default a socket here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahhh, got it; thanks for the added detail. |
||
rt = windowsV1RuntimeName | ||
} else { | ||
rt = windowsV2RuntimeName | ||
} | ||
} | ||
|
||
switch rt { | ||
case windowsV1RuntimeName: | ||
daemon.containerd, err = local.NewClient( | ||
ctx, | ||
daemon.containerdCli, | ||
filepath.Join(daemon.configStore.ExecRoot, "containerd"), | ||
daemon.configStore.ContainerdNamespace, | ||
daemon, | ||
) | ||
case windowsV2RuntimeName: | ||
if daemon.configStore.ContainerdAddr == "" { | ||
return fmt.Errorf("cannot use the specified runtime %q without containerd", rt) | ||
} | ||
daemon.containerd, err = remote.NewClient( | ||
ctx, | ||
daemon.containerdCli, | ||
filepath.Join(daemon.configStore.ExecRoot, "containerd"), | ||
daemon.configStore.ContainerdNamespace, | ||
daemon, | ||
) | ||
default: | ||
return fmt.Errorf("unknown windows runtime %s", rt) | ||
} | ||
|
||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole
StockRuntimeName
vsDefaultRuntimeName
is a bit confusing.Wondering, will setting this to an empty string cause some odd behavior if somehow the option is set to an empty string?
moby/opts/runtime.go
Lines 44 to 46 in 7b9275c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, never mind; looks like we first check if it's not empty;
moby/opts/runtime.go
Lines 39 to 41 in 7b9275c