2015-04-29 18:53:35 -04:00
|
|
|
// +build windows
|
|
|
|
|
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2015-09-10 18:01:18 -04:00
|
|
|
"github.com/docker/docker/context"
|
2015-04-29 18:53:35 -04:00
|
|
|
"github.com/docker/docker/daemon/execdriver"
|
2015-09-17 14:54:14 -04:00
|
|
|
derr "github.com/docker/docker/errors"
|
2015-04-29 18:53:35 -04:00
|
|
|
)
|
|
|
|
|
2015-07-30 17:01:53 -04:00
|
|
|
// DefaultPathEnv is deliberately empty on Windows as the default path will be set by
|
2015-06-01 19:42:27 -04:00
|
|
|
// the container. Docker has no context of what the default path should be.
|
|
|
|
const DefaultPathEnv = ""
|
2015-04-29 18:53:35 -04:00
|
|
|
|
2015-07-30 17:01:53 -04:00
|
|
|
// Container holds fields specific to the Windows implementation. See
|
|
|
|
// CommonContainer for standard fields common to all containers.
|
2015-04-29 18:53:35 -04:00
|
|
|
type Container struct {
|
|
|
|
CommonContainer
|
|
|
|
|
|
|
|
// Fields below here are platform specific.
|
|
|
|
}
|
|
|
|
|
|
|
|
func killProcessDirectly(container *Container) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-09-10 18:01:18 -04:00
|
|
|
func (container *Container) setupLinkedContainers(ctx context.Context) ([]string, error) {
|
2015-04-29 18:53:35 -04:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (container *Container) createDaemonEnvironment(linkedEnv []string) []string {
|
2015-06-01 19:42:27 -04:00
|
|
|
// On Windows, nothing to link. Just return the container environment.
|
|
|
|
return container.Config.Env
|
2015-04-29 18:53:35 -04:00
|
|
|
}
|
|
|
|
|
2015-09-10 18:01:18 -04:00
|
|
|
func (container *Container) initializeNetworking(ctx context.Context) error {
|
2015-04-29 18:53:35 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (container *Container) setupWorkingDirectory() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-09-10 18:01:18 -04:00
|
|
|
func populateCommand(ctx context.Context, c *Container, env []string) error {
|
2015-04-29 18:53:35 -04:00
|
|
|
en := &execdriver.Network{
|
|
|
|
Interface: nil,
|
|
|
|
}
|
|
|
|
|
|
|
|
parts := strings.SplitN(string(c.hostConfig.NetworkMode), ":", 2)
|
|
|
|
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,
|
2015-07-30 17:01:53 -04:00
|
|
|
Bridge: c.daemon.configStore.Bridge.VirtualSwitchName,
|
2015-08-06 22:21:00 -04: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 18:53:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
2015-09-16 14:56:26 -04:00
|
|
|
return derr.ErrorCodeInvalidNetworkMode.WithArgs(c.hostConfig.NetworkMode)
|
2015-04-29 18:53:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
pid := &execdriver.Pid{}
|
|
|
|
|
|
|
|
// TODO Windows. This can probably be factored out.
|
|
|
|
pid.HostPid = c.hostConfig.PidMode.IsHost()
|
|
|
|
|
2015-09-22 19:05:00 -04:00
|
|
|
// TODO Windows. More resource controls to be implemented later.
|
|
|
|
resources := &execdriver.Resources{
|
|
|
|
CPUShares: c.hostConfig.CPUShares,
|
|
|
|
}
|
2015-04-29 18:53:35 -04:00
|
|
|
|
|
|
|
// TODO Windows. Further refactoring required (privileged/user)
|
|
|
|
processConfig := execdriver.ProcessConfig{
|
2015-05-27 16:15:14 -04: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 18:53:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
processConfig.Env = env
|
|
|
|
|
2015-06-11 14:29:29 -04:00
|
|
|
var layerPaths []string
|
2015-07-24 20:49:43 -04:00
|
|
|
img, err := c.daemon.graph.Get(c.ImageID)
|
|
|
|
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
|
|
|
}
|
|
|
|
for i := img; i != nil && err == nil; i, err = c.daemon.graph.GetParent(i) {
|
|
|
|
lp, err := c.daemon.driver.Get(i.ID, "")
|
|
|
|
if err != nil {
|
2015-09-16 14:56:26 -04:00
|
|
|
return derr.ErrorCodeGetLayer.WithArgs(c.daemon.driver.String(), i.ID, err)
|
2015-06-11 14:29:29 -04:00
|
|
|
}
|
2015-07-24 20:49:43 -04:00
|
|
|
layerPaths = append(layerPaths, lp)
|
|
|
|
err = c.daemon.driver.Put(i.ID)
|
|
|
|
if err != nil {
|
2015-09-16 14:56:26 -04:00
|
|
|
return derr.ErrorCodePutLayer.WithArgs(c.daemon.driver.String(), i.ID, err)
|
2015-06-11 14:29:29 -04:00
|
|
|
}
|
|
|
|
}
|
2015-07-24 20:49:43 -04:00
|
|
|
m, err := c.daemon.driver.GetMetadata(c.ID)
|
|
|
|
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-04-29 18:53:35 -04:00
|
|
|
// TODO Windows: Factor out remainder of unused fields.
|
|
|
|
c.command = &execdriver.Command{
|
|
|
|
ID: c.ID,
|
2015-07-30 17:01:53 -04:00
|
|
|
Rootfs: c.rootfsPath(),
|
2015-04-29 18:53:35 -04:00
|
|
|
ReadonlyRootfs: c.hostConfig.ReadonlyRootfs,
|
|
|
|
InitPath: "/.dockerinit",
|
|
|
|
WorkingDir: c.Config.WorkingDir,
|
|
|
|
Network: en,
|
|
|
|
Pid: pid,
|
|
|
|
Resources: resources,
|
2015-07-01 13:59:18 -04:00
|
|
|
CapAdd: c.hostConfig.CapAdd.Slice(),
|
|
|
|
CapDrop: c.hostConfig.CapDrop.Slice(),
|
2015-04-29 18:53:35 -04:00
|
|
|
ProcessConfig: processConfig,
|
2015-07-30 17:01:53 -04:00
|
|
|
ProcessLabel: c.getProcessLabel(),
|
|
|
|
MountLabel: c.getMountLabel(),
|
2015-05-27 16:15:14 -04:00
|
|
|
FirstStart: !c.HasBeenStartedBefore,
|
2015-06-11 14:29:29 -04:00
|
|
|
LayerFolder: layerFolder,
|
|
|
|
LayerPaths: layerPaths,
|
2015-04-29 18:53:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-07-30 17:01:53 -04:00
|
|
|
// GetSize returns real size & virtual size
|
2015-09-10 18:01:18 -04:00
|
|
|
func (container *Container) getSize(ctx context.Context) (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.
|
|
|
|
func (container *Container) setNetworkNamespaceKey(pid int) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-07-30 17:01:53 -04:00
|
|
|
// allocateNetwork is a no-op on Windows.
|
|
|
|
func (container *Container) allocateNetwork() error {
|
2015-04-29 18:53:35 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-09-10 18:01:18 -04:00
|
|
|
func (container *Container) updateNetwork(ctx context.Context) error {
|
2015-07-30 17:01:53 -04:00
|
|
|
return nil
|
2015-04-29 18:53:35 -04:00
|
|
|
}
|
|
|
|
|
2015-07-30 17:01:53 -04:00
|
|
|
func (container *Container) releaseNetwork() {
|
2015-04-29 18:53:35 -04:00
|
|
|
}
|
2015-05-26 12:33:55 -04:00
|
|
|
|
2015-07-30 17:01:53 -04:00
|
|
|
func (container *Container) unmountVolumes(forceSyscall bool) error {
|
2015-05-26 12:33:55 -04:00
|
|
|
return nil
|
|
|
|
}
|
2015-06-11 14:29:29 -04:00
|
|
|
|
2015-07-30 17:46:51 -04:00
|
|
|
// prepareMountPoints is a no-op on Windows
|
2015-07-16 17:14:58 -04:00
|
|
|
func (container *Container) prepareMountPoints() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-07-30 17:46:51 -04:00
|
|
|
// removeMountPoints is a no-op on Windows.
|
2015-06-12 09:25:32 -04:00
|
|
|
func (container *Container) removeMountPoints(_ bool) error {
|
2015-07-16 17:14:58 -04:00
|
|
|
return nil
|
|
|
|
}
|
2015-08-03 18:05:34 -04:00
|
|
|
|
|
|
|
func (container *Container) setupIpcDirs() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (container *Container) unmountIpcMounts() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (container *Container) ipcMounts() []execdriver.Mount {
|
|
|
|
return nil
|
|
|
|
}
|
2015-09-24 17:59:23 -04:00
|
|
|
|
|
|
|
func getDefaultRouteMtu() (int, error) {
|
|
|
|
return -1, errSystemNotSupported
|
|
|
|
}
|