2015-04-29 18:53:35 -04:00
|
|
|
// +build windows
|
|
|
|
|
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2015-11-12 14:55:17 -05:00
|
|
|
"github.com/docker/docker/container"
|
2015-04-29 18:53:35 -04:00
|
|
|
"github.com/docker/docker/daemon/execdriver"
|
2015-12-18 13:36:17 -05:00
|
|
|
"github.com/docker/docker/daemon/execdriver/windows"
|
2015-09-17 14:54:14 -04:00
|
|
|
derr "github.com/docker/docker/errors"
|
2015-11-18 17:20:54 -05:00
|
|
|
"github.com/docker/docker/layer"
|
2016-01-07 19:18:34 -05:00
|
|
|
networktypes "github.com/docker/engine-api/types/network"
|
2015-12-03 14:10:27 -05:00
|
|
|
"github.com/docker/libnetwork"
|
2015-04-29 18:53:35 -04:00
|
|
|
)
|
|
|
|
|
2015-11-12 14:55:17 -05:00
|
|
|
func (daemon *Daemon) setupLinkedContainers(container *container.Container) ([]string, error) {
|
2015-04-29 18:53:35 -04:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2015-12-13 02:33:18 -05:00
|
|
|
// updateContainerNetworkSettings update the network settings
|
2016-01-07 19:18:34 -05:00
|
|
|
func (daemon *Daemon) updateContainerNetworkSettings(container *container.Container, endpointsConfig map[string]*networktypes.EndpointSettings) error {
|
2015-12-13 02:33:18 -05:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-11-12 14:55:17 -05:00
|
|
|
func (daemon *Daemon) initializeNetworking(container *container.Container) error {
|
2015-04-29 18:53:35 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-09-25 06:19:17 -04:00
|
|
|
// ConnectToNetwork connects a container to the network
|
2016-01-07 19:18:34 -05:00
|
|
|
func (daemon *Daemon) ConnectToNetwork(container *container.Container, idOrName string, endpointConfig *networktypes.EndpointSettings) error {
|
2015-09-25 06:19:17 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-01-12 23:56:36 -05:00
|
|
|
// ForceEndpointDelete deletes an endpoing from a network forcefully
|
|
|
|
func (daemon *Daemon) ForceEndpointDelete(name string, n libnetwork.Network) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-12-03 14:10:27 -05:00
|
|
|
// DisconnectFromNetwork disconnects a container from the network.
|
2016-01-12 23:56:36 -05:00
|
|
|
func (daemon *Daemon) DisconnectFromNetwork(container *container.Container, n libnetwork.Network, force bool) error {
|
2015-12-03 14:10:27 -05:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-11-12 14:55:17 -05:00
|
|
|
func (daemon *Daemon) populateCommand(c *container.Container, env []string) error {
|
2015-04-29 18:53:35 -04:00
|
|
|
en := &execdriver.Network{
|
|
|
|
Interface: nil,
|
|
|
|
}
|
|
|
|
|
2015-11-12 14:55:17 -05:00
|
|
|
parts := strings.SplitN(string(c.HostConfig.NetworkMode), ":", 2)
|
2015-04-29 18:53:35 -04:00
|
|
|
switch parts[0] {
|
|
|
|
case "none":
|
2015-06-23 13:13:42 -04:00
|
|
|
case "default", "": // empty string to support existing containers
|
2015-04-29 18:53:35 -04:00
|
|
|
if !c.Config.NetworkDisabled {
|
|
|
|
en.Interface = &execdriver.NetworkInterface{
|
2015-08-06 22:21:00 -04:00
|
|
|
MacAddress: c.Config.MacAddress,
|
2016-01-25 16:30:33 -05:00
|
|
|
Bridge: daemon.configStore.bridgeConfig.VirtualSwitchName,
|
2015-11-12 14:55:17 -05:00
|
|
|
PortBindings: c.HostConfig.PortBindings,
|
2015-08-06 22:21:00 -04:00
|
|
|
|
|
|
|
// 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 18:53:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
2015-11-12 14:55:17 -05:00
|
|
|
return derr.ErrorCodeInvalidNetworkMode.WithArgs(c.HostConfig.NetworkMode)
|
2015-04-29 18:53:35 -04:00
|
|
|
}
|
|
|
|
|
2015-09-22 19:05:00 -04:00
|
|
|
// TODO Windows. More resource controls to be implemented later.
|
|
|
|
resources := &execdriver.Resources{
|
2015-10-05 13:11:10 -04:00
|
|
|
CommonResources: execdriver.CommonResources{
|
2015-11-12 14:55:17 -05:00
|
|
|
CPUShares: c.HostConfig.CPUShares,
|
2015-10-05 13:11:10 -04:00
|
|
|
},
|
2015-09-22 19:05:00 -04:00
|
|
|
}
|
2015-04-29 18:53:35 -04:00
|
|
|
|
|
|
|
processConfig := execdriver.ProcessConfig{
|
2015-11-01 10:53:15 -05:00
|
|
|
CommonProcessConfig: execdriver.CommonProcessConfig{
|
|
|
|
Entrypoint: c.Path,
|
|
|
|
Arguments: c.Args,
|
|
|
|
Tty: c.Config.Tty,
|
|
|
|
},
|
2015-11-12 14:55:17 -05:00
|
|
|
ConsoleSize: c.HostConfig.ConsoleSize,
|
2015-04-29 18:53:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
processConfig.Env = env
|
|
|
|
|
2015-06-11 14:29:29 -04:00
|
|
|
var layerPaths []string
|
2015-11-18 17:20:54 -05:00
|
|
|
img, err := daemon.imageStore.Get(c.ImageID)
|
2015-07-24 20:49:43 -04:00
|
|
|
if err != nil {
|
2015-09-16 14:56:26 -04:00
|
|
|
return derr.ErrorCodeGetGraph.WithArgs(c.ImageID, err)
|
2015-07-24 20:49:43 -04:00
|
|
|
}
|
2015-11-18 17:20:54 -05:00
|
|
|
|
|
|
|
if img.RootFS != nil && img.RootFS.Type == "layers+base" {
|
|
|
|
max := len(img.RootFS.DiffIDs)
|
|
|
|
for i := 0; i <= max; i++ {
|
|
|
|
img.RootFS.DiffIDs = img.RootFS.DiffIDs[:i]
|
|
|
|
path, err := layer.GetLayerPath(daemon.layerStore, img.RootFS.ChainID())
|
|
|
|
if err != nil {
|
|
|
|
return derr.ErrorCodeGetLayer.WithArgs(err)
|
|
|
|
}
|
|
|
|
// Reverse order, expecting parent most first
|
|
|
|
layerPaths = append([]string{path}, layerPaths...)
|
2015-06-11 14:29:29 -04:00
|
|
|
}
|
|
|
|
}
|
2015-11-18 17:20:54 -05:00
|
|
|
|
2015-12-16 17:13:50 -05:00
|
|
|
m, err := c.RWLayer.Metadata()
|
2015-07-24 20:49:43 -04:00
|
|
|
if err != nil {
|
2015-09-16 14:56:26 -04:00
|
|
|
return derr.ErrorCodeGetLayerMetadata.WithArgs(err)
|
2015-07-24 20:49:43 -04:00
|
|
|
}
|
|
|
|
layerFolder := m["dir"]
|
2015-06-11 14:29:29 -04:00
|
|
|
|
2015-12-18 13:36:17 -05:00
|
|
|
var hvPartition bool
|
|
|
|
// Work out the isolation (whether it is a hypervisor partition)
|
|
|
|
if c.HostConfig.Isolation.IsDefault() {
|
|
|
|
// Not specified by caller. Take daemon default
|
|
|
|
hvPartition = windows.DefaultIsolation.IsHyperV()
|
|
|
|
} else {
|
|
|
|
// Take value specified by caller
|
|
|
|
hvPartition = c.HostConfig.Isolation.IsHyperV()
|
|
|
|
}
|
|
|
|
|
2015-11-12 14:55:17 -05:00
|
|
|
c.Command = &execdriver.Command{
|
2015-10-05 17:27:39 -04:00
|
|
|
CommonCommand: execdriver.CommonCommand{
|
|
|
|
ID: c.ID,
|
2015-11-12 14:55:17 -05:00
|
|
|
Rootfs: c.BaseFS,
|
2015-10-05 17:27:39 -04:00
|
|
|
WorkingDir: c.Config.WorkingDir,
|
|
|
|
Network: en,
|
2015-11-12 14:55:17 -05:00
|
|
|
MountLabel: c.GetMountLabel(),
|
2015-10-05 17:27:39 -04:00
|
|
|
Resources: resources,
|
|
|
|
ProcessConfig: processConfig,
|
2015-11-12 14:55:17 -05:00
|
|
|
ProcessLabel: c.GetProcessLabel(),
|
2015-10-05 17:27:39 -04:00
|
|
|
},
|
|
|
|
FirstStart: !c.HasBeenStartedBefore,
|
|
|
|
LayerFolder: layerFolder,
|
|
|
|
LayerPaths: layerPaths,
|
|
|
|
Hostname: c.Config.Hostname,
|
2015-12-18 13:36:17 -05:00
|
|
|
Isolation: string(c.HostConfig.Isolation),
|
2015-11-09 14:49:16 -05:00
|
|
|
ArgsEscaped: c.Config.ArgsEscaped,
|
2015-12-18 13:36:17 -05:00
|
|
|
HvPartition: hvPartition,
|
2015-04-29 18:53:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-11-02 20:06:09 -05:00
|
|
|
// getSize returns real size & virtual size
|
2015-11-12 14:55:17 -05:00
|
|
|
func (daemon *Daemon) getSize(container *container.Container) (int64, int64) {
|
2015-04-29 18:53:35 -04:00
|
|
|
// TODO Windows
|
|
|
|
return 0, 0
|
|
|
|
}
|
|
|
|
|
2015-09-11 15:05:57 -04:00
|
|
|
// setNetworkNamespaceKey is a no-op on Windows.
|
2015-11-03 14:25:22 -05:00
|
|
|
func (daemon *Daemon) setNetworkNamespaceKey(containerID string, pid int) error {
|
2015-09-11 15:05:57 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-07-30 17:01:53 -04:00
|
|
|
// allocateNetwork is a no-op on Windows.
|
2015-11-12 14:55:17 -05:00
|
|
|
func (daemon *Daemon) allocateNetwork(container *container.Container) error {
|
2015-04-29 18:53:35 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-11-12 14:55:17 -05:00
|
|
|
func (daemon *Daemon) updateNetwork(container *container.Container) error {
|
2015-08-03 18:05:34 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-11-12 14:55:17 -05:00
|
|
|
func (daemon *Daemon) releaseNetwork(container *container.Container) {
|
2015-10-30 14:55:52 -04:00
|
|
|
}
|
|
|
|
|
2015-11-12 14:55:17 -05:00
|
|
|
func (daemon *Daemon) setupIpcDirs(container *container.Container) error {
|
2015-08-03 18:05:34 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-11-12 14:55:17 -05:00
|
|
|
// TODO Windows: Fix Post-TP4. This is a hack to allow docker cp to work
|
|
|
|
// against containers which have volumes. You will still be able to cp
|
|
|
|
// to somewhere on the container drive, but not to any mounted volumes
|
|
|
|
// inside the container. Without this fix, docker cp is broken to any
|
|
|
|
// container which has a volume, regardless of where the file is inside the
|
|
|
|
// container.
|
|
|
|
func (daemon *Daemon) mountVolumes(container *container.Container) error {
|
2015-08-03 18:05:34 -04:00
|
|
|
return nil
|
|
|
|
}
|
2015-09-24 17:59:23 -04:00
|
|
|
|
2015-11-12 14:55:17 -05:00
|
|
|
func detachMounted(path string) error {
|
2015-12-01 13:39:34 -05:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-11-12 14:55:17 -05:00
|
|
|
func killProcessDirectly(container *container.Container) error {
|
2015-11-11 16:53:38 -05:00
|
|
|
return nil
|
|
|
|
}
|