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-11-18 22:20:54 +00:00
|
|
|
"github.com/docker/docker/layer"
|
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
|
|
|
|
|
|
|
processConfig := execdriver.ProcessConfig{
|
2015-11-01 15:53:15 +00:00
|
|
|
CommonProcessConfig: execdriver.CommonProcessConfig{
|
|
|
|
Entrypoint: c.Path,
|
|
|
|
Arguments: c.Args,
|
|
|
|
Tty: c.Config.Tty,
|
|
|
|
},
|
2015-05-27 20:15:14 +00:00
|
|
|
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-18 22:20:54 +00:00
|
|
|
img, err := daemon.imageStore.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-18 22:20:54 +00: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 18:29:29 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-18 22:20:54 +00:00
|
|
|
|
|
|
|
m, err := layer.RWLayerMetadata(daemon.layerStore, 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,
|
2015-11-01 02:16:58 +00:00
|
|
|
Isolation: c.hostConfig.Isolation,
|
2015-11-09 19:49:16 +00:00
|
|
|
ArgsEscaped: c.Config.ArgsEscaped,
|
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
|
|
|
|
2015-12-01 18:39:34 +00:00
|
|
|
func (container *Container) tmpfsMounts() []execdriver.Mount {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-09-24 21:59:23 +00:00
|
|
|
func getDefaultRouteMtu() (int, error) {
|
|
|
|
return -1, errSystemNotSupported
|
|
|
|
}
|
2015-11-11 21:53:38 +00: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) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
func (container *Container) unmountVolumes(forceSyscall bool) error {
|
|
|
|
return nil
|
|
|
|
}
|