2015-04-29 22:53:35 +00:00
|
|
|
// +build windows
|
|
|
|
|
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/docker/docker/daemon/execdriver"
|
2015-09-17 18:54:14 +00:00
|
|
|
derr "github.com/docker/docker/errors"
|
2015-09-10 02:23:06 +00:00
|
|
|
"github.com/docker/docker/volume"
|
2015-09-25 10:19:17 +00:00
|
|
|
"github.com/docker/libnetwork"
|
2015-04-29 22:53:35 +00:00
|
|
|
)
|
|
|
|
|
2015-07-30 21:01:53 +00:00
|
|
|
// DefaultPathEnv is deliberately empty on Windows as the default path will be set by
|
2015-06-01 23:42:27 +00:00
|
|
|
// the container. Docker has no context of what the default path should be.
|
|
|
|
const DefaultPathEnv = ""
|
2015-04-29 22:53:35 +00:00
|
|
|
|
2015-07-30 21:01:53 +00:00
|
|
|
// Container holds fields specific to the Windows implementation. See
|
|
|
|
// CommonContainer for standard fields common to all containers.
|
2015-04-29 22:53:35 +00:00
|
|
|
type Container struct {
|
|
|
|
CommonContainer
|
|
|
|
|
|
|
|
// Fields below here are platform specific.
|
|
|
|
}
|
|
|
|
|
|
|
|
func killProcessDirectly(container *Container) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-11-03 18:25:09 +00:00
|
|
|
func (daemon *Daemon) setupLinkedContainers(container *Container) ([]string, error) {
|
2015-04-29 22:53:35 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (container *Container) createDaemonEnvironment(linkedEnv []string) []string {
|
2015-06-01 23:42:27 +00:00
|
|
|
// On Windows, nothing to link. Just return the container environment.
|
|
|
|
return container.Config.Env
|
2015-04-29 22:53:35 +00:00
|
|
|
}
|
|
|
|
|
2015-11-03 18:25:09 +00:00
|
|
|
func (daemon *Daemon) initializeNetworking(container *Container) error {
|
2015-04-29 22:53:35 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-09-25 10:19:17 +00:00
|
|
|
// ConnectToNetwork connects a container to the network
|
2015-11-03 18:25:09 +00:00
|
|
|
func (daemon *Daemon) ConnectToNetwork(container *Container, idOrName string) error {
|
2015-09-25 10:19:17 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// DisconnectFromNetwork disconnects a container from, the network
|
|
|
|
func (container *Container) DisconnectFromNetwork(n libnetwork.Network) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-04-29 22:53:35 +00:00
|
|
|
func (container *Container) setupWorkingDirectory() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-11-03 18:25:09 +00:00
|
|
|
func (daemon *Daemon) populateCommand(c *Container, env []string) error {
|
2015-04-29 22:53:35 +00:00
|
|
|
en := &execdriver.Network{
|
|
|
|
Interface: nil,
|
|
|
|
}
|
|
|
|
|
|
|
|
parts := strings.SplitN(string(c.hostConfig.NetworkMode), ":", 2)
|
|
|
|
switch parts[0] {
|
|
|
|
case "none":
|
2015-06-23 17:13:42 +00:00
|
|
|
case "default", "": // empty string to support existing containers
|
2015-04-29 22:53:35 +00:00
|
|
|
if !c.Config.NetworkDisabled {
|
|
|
|
en.Interface = &execdriver.NetworkInterface{
|
2015-08-07 02:21:00 +00:00
|
|
|
MacAddress: c.Config.MacAddress,
|
2015-11-03 18:25:09 +00:00
|
|
|
Bridge: daemon.configStore.Bridge.VirtualSwitchName,
|
2015-08-07 02:21:00 +00:00
|
|
|
PortBindings: c.hostConfig.PortBindings,
|
|
|
|
|
|
|
|
// TODO Windows. Include IPAddress. There already is a
|
|
|
|
// property IPAddress on execDrive.CommonNetworkInterface,
|
|
|
|
// but there is no CLI option in docker to pass through
|
|
|
|
// an IPAddress on docker run.
|
2015-04-29 22:53:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
2015-09-16 18:56:26 +00:00
|
|
|
return derr.ErrorCodeInvalidNetworkMode.WithArgs(c.hostConfig.NetworkMode)
|
2015-04-29 22:53:35 +00:00
|
|
|
}
|
|
|
|
|
2015-09-22 23:05:00 +00:00
|
|
|
// TODO Windows. More resource controls to be implemented later.
|
|
|
|
resources := &execdriver.Resources{
|
2015-10-05 17:11:10 +00:00
|
|
|
CommonResources: execdriver.CommonResources{
|
|
|
|
CPUShares: c.hostConfig.CPUShares,
|
|
|
|
},
|
2015-09-22 23:05:00 +00:00
|
|
|
}
|
2015-04-29 22:53:35 +00:00
|
|
|
|
|
|
|
// TODO Windows. Further refactoring required (privileged/user)
|
|
|
|
processConfig := execdriver.ProcessConfig{
|
2015-05-27 20:15:14 +00:00
|
|
|
Privileged: c.hostConfig.Privileged,
|
|
|
|
Entrypoint: c.Path,
|
|
|
|
Arguments: c.Args,
|
|
|
|
Tty: c.Config.Tty,
|
|
|
|
User: c.Config.User,
|
|
|
|
ConsoleSize: c.hostConfig.ConsoleSize,
|
2015-04-29 22:53:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
processConfig.Env = env
|
|
|
|
|
2015-06-11 18:29:29 +00:00
|
|
|
var layerPaths []string
|
2015-11-03 18:25:09 +00:00
|
|
|
img, err := daemon.graph.Get(c.ImageID)
|
2015-07-25 00:49:43 +00:00
|
|
|
if err != nil {
|
2015-09-16 18:56:26 +00:00
|
|
|
return derr.ErrorCodeGetGraph.WithArgs(c.ImageID, err)
|
2015-07-25 00:49:43 +00:00
|
|
|
}
|
2015-11-03 18:25:09 +00:00
|
|
|
for i := img; i != nil && err == nil; i, err = daemon.graph.GetParent(i) {
|
|
|
|
lp, err := daemon.driver.Get(i.ID, "")
|
2015-07-25 00:49:43 +00:00
|
|
|
if err != nil {
|
2015-11-03 18:25:09 +00:00
|
|
|
return derr.ErrorCodeGetLayer.WithArgs(daemon.driver.String(), i.ID, err)
|
2015-06-11 18:29:29 +00:00
|
|
|
}
|
2015-07-25 00:49:43 +00:00
|
|
|
layerPaths = append(layerPaths, lp)
|
2015-11-03 18:25:09 +00:00
|
|
|
err = daemon.driver.Put(i.ID)
|
2015-07-25 00:49:43 +00:00
|
|
|
if err != nil {
|
2015-11-03 18:25:09 +00:00
|
|
|
return derr.ErrorCodePutLayer.WithArgs(daemon.driver.String(), i.ID, err)
|
2015-06-11 18:29:29 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-03 18:25:09 +00:00
|
|
|
m, err := daemon.driver.GetMetadata(c.ID)
|
2015-07-25 00:49:43 +00:00
|
|
|
if err != nil {
|
2015-09-16 18:56:26 +00:00
|
|
|
return derr.ErrorCodeGetLayerMetadata.WithArgs(err)
|
2015-07-25 00:49:43 +00:00
|
|
|
}
|
|
|
|
layerFolder := m["dir"]
|
2015-06-11 18:29:29 +00:00
|
|
|
|
2015-04-29 22:53:35 +00:00
|
|
|
c.command = &execdriver.Command{
|
2015-10-05 21:27:39 +00:00
|
|
|
CommonCommand: execdriver.CommonCommand{
|
|
|
|
ID: c.ID,
|
|
|
|
Rootfs: c.rootfsPath(),
|
|
|
|
InitPath: "/.dockerinit",
|
|
|
|
WorkingDir: c.Config.WorkingDir,
|
|
|
|
Network: en,
|
|
|
|
MountLabel: c.getMountLabel(),
|
|
|
|
Resources: resources,
|
|
|
|
ProcessConfig: processConfig,
|
|
|
|
ProcessLabel: c.getProcessLabel(),
|
|
|
|
},
|
|
|
|
FirstStart: !c.HasBeenStartedBefore,
|
|
|
|
LayerFolder: layerFolder,
|
|
|
|
LayerPaths: layerPaths,
|
|
|
|
Hostname: c.Config.Hostname,
|
|
|
|
Isolated: c.hostConfig.Isolation.IsHyperV(),
|
2015-04-29 22:53:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-11-03 01:06:09 +00:00
|
|
|
// getSize returns real size & virtual size
|
|
|
|
func (daemon *Daemon) getSize(container *Container) (int64, int64) {
|
2015-04-29 22:53:35 +00:00
|
|
|
// TODO Windows
|
|
|
|
return 0, 0
|
|
|
|
}
|
|
|
|
|
2015-09-11 19:05:57 +00:00
|
|
|
// setNetworkNamespaceKey is a no-op on Windows.
|
2015-11-03 19:25:22 +00:00
|
|
|
func (daemon *Daemon) setNetworkNamespaceKey(containerID string, pid int) error {
|
2015-09-11 19:05:57 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-07-30 21:01:53 +00:00
|
|
|
// allocateNetwork is a no-op on Windows.
|
2015-11-03 18:25:09 +00:00
|
|
|
func (daemon *Daemon) allocateNetwork(container *Container) error {
|
2015-04-29 22:53:35 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-11-03 18:25:09 +00:00
|
|
|
func (daemon *Daemon) updateNetwork(container *Container) error {
|
2015-07-30 21:01:53 +00:00
|
|
|
return nil
|
2015-04-29 22:53:35 +00:00
|
|
|
}
|
|
|
|
|
2015-11-03 17:43:36 +00:00
|
|
|
func (daemon *Daemon) releaseNetwork(container *Container) {
|
2015-04-29 22:53:35 +00:00
|
|
|
}
|
2015-05-26 16:33:55 +00:00
|
|
|
|
2015-09-10 02:23:06 +00:00
|
|
|
// appendNetworkMounts appends any network mounts to the array of mount points passed in.
|
|
|
|
// Windows does not support network mounts (not to be confused with SMB network mounts), so
|
|
|
|
// this is a no-op.
|
|
|
|
func appendNetworkMounts(container *Container, volumeMounts []volume.MountPoint) ([]volume.MountPoint, error) {
|
|
|
|
return volumeMounts, nil
|
2015-07-16 21:14:58 +00:00
|
|
|
}
|
2015-08-03 22:05:34 +00:00
|
|
|
|
2015-11-03 18:25:09 +00:00
|
|
|
func (daemon *Daemon) setupIpcDirs(container *Container) error {
|
2015-08-03 22:05:34 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-10-30 23:00:01 +00:00
|
|
|
func (container *Container) unmountIpcMounts(unmount func(pth string) error) {
|
2015-10-30 18:55:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func detachMounted(path string) error {
|
2015-08-03 22:05:34 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (container *Container) ipcMounts() []execdriver.Mount {
|
|
|
|
return nil
|
|
|
|
}
|
2015-09-24 21:59:23 +00:00
|
|
|
|
|
|
|
func getDefaultRouteMtu() (int, error) {
|
|
|
|
return -1, errSystemNotSupported
|
|
|
|
}
|