func makeSandboxDockerConfig(c *runtimeApi.PodSandboxConfig, image string) *dockertypes.ContainerCreateConfig { // Merge annotations and labels because docker supports only labels. labels := makeLabels(c.GetLabels(), c.GetAnnotations()) // Apply a label to distinguish sandboxes from regular containers. labels[containerTypeLabelKey] = containerTypeLabelSandbox hc := &dockercontainer.HostConfig{} createConfig := &dockertypes.ContainerCreateConfig{ Name: c.GetName(), Config: &dockercontainer.Config{ Hostname: c.GetHostname(), // TODO: Handle environment variables. Image: image, Labels: labels, }, HostConfig: hc, } // Apply linux-specific options. if lc := c.GetLinux(); lc != nil { // Apply Cgroup options. // TODO: Check if this works with per-pod cgroups. hc.CgroupParent = lc.GetCgroupParent() // Apply namespace options. hc.NetworkMode, hc.UTSMode, hc.PidMode = "", "", "" nsOpts := lc.GetNamespaceOptions() if nsOpts != nil { if nsOpts.GetHostNetwork() { hc.NetworkMode = namespaceModeHost } else { // Assume kubelet uses either the cni or the kubenet plugin. // TODO: support docker networking. hc.NetworkMode = "none" } if nsOpts.GetHostIpc() { hc.IpcMode = namespaceModeHost } if nsOpts.GetHostPid() { hc.PidMode = namespaceModeHost } } } // Set port mappings. exposedPorts, portBindings := makePortsAndBindings(c.GetPortMappings()) createConfig.Config.ExposedPorts = exposedPorts hc.PortBindings = portBindings // Set DNS options. if dnsOpts := c.GetDnsOptions(); dnsOpts != nil { hc.DNS = dnsOpts.GetServers() hc.DNSSearch = dnsOpts.GetSearches() } // Apply resource options. setSandboxResources(c.GetResources(), hc) // Set security options. hc.SecurityOpt = []string{getSeccompOpts()} return createConfig }