2015-04-29 22:53:35 +00:00
|
|
|
// +build windows
|
|
|
|
|
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/docker/docker/daemon/execdriver"
|
|
|
|
)
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
func (container *Container) setupLinkedContainers() ([]string, error) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
func (container *Container) initializeNetworking() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (container *Container) setupWorkingDirectory() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func populateCommand(c *Container, env []string) error {
|
|
|
|
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-07-30 21:01:53 +00:00
|
|
|
Bridge: c.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:
|
|
|
|
return fmt.Errorf("invalid network mode: %s", c.hostConfig.NetworkMode)
|
|
|
|
}
|
|
|
|
|
|
|
|
pid := &execdriver.Pid{}
|
|
|
|
|
|
|
|
// TODO Windows. This can probably be factored out.
|
|
|
|
pid.HostPid = c.hostConfig.PidMode.IsHost()
|
|
|
|
|
|
|
|
// TODO Windows. Resource controls to be implemented later.
|
|
|
|
resources := &execdriver.Resources{}
|
|
|
|
|
|
|
|
// 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-07-25 00:49:43 +00:00
|
|
|
img, err := c.daemon.graph.Get(c.ImageID)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("Failed to graph.Get on ImageID %s - %s", c.ImageID, err)
|
|
|
|
}
|
|
|
|
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 {
|
|
|
|
return fmt.Errorf("Failed to get layer path from graphdriver %s for ImageID %s - %s", c.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)
|
|
|
|
err = c.daemon.driver.Put(i.ID)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("Failed to put layer path from graphdriver %s for ImageID %s - %s", c.daemon.driver.String(), i.ID, err)
|
2015-06-11 18:29:29 +00:00
|
|
|
}
|
|
|
|
}
|
2015-07-25 00:49:43 +00:00
|
|
|
m, err := c.daemon.driver.GetMetadata(c.ID)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("Failed to get layer metadata - %s", err)
|
|
|
|
}
|
|
|
|
layerFolder := m["dir"]
|
2015-06-11 18:29:29 +00:00
|
|
|
|
2015-04-29 22:53:35 +00:00
|
|
|
// TODO Windows: Factor out remainder of unused fields.
|
|
|
|
c.command = &execdriver.Command{
|
|
|
|
ID: c.ID,
|
2015-07-30 21:01:53 +00:00
|
|
|
Rootfs: c.rootfsPath(),
|
2015-04-29 22:53:35 +00:00
|
|
|
ReadonlyRootfs: c.hostConfig.ReadonlyRootfs,
|
|
|
|
InitPath: "/.dockerinit",
|
|
|
|
WorkingDir: c.Config.WorkingDir,
|
|
|
|
Network: en,
|
|
|
|
Pid: pid,
|
|
|
|
Resources: resources,
|
2015-07-01 17:59:18 +00:00
|
|
|
CapAdd: c.hostConfig.CapAdd.Slice(),
|
|
|
|
CapDrop: c.hostConfig.CapDrop.Slice(),
|
2015-04-29 22:53:35 +00:00
|
|
|
ProcessConfig: processConfig,
|
2015-07-30 21:01:53 +00:00
|
|
|
ProcessLabel: c.getProcessLabel(),
|
|
|
|
MountLabel: c.getMountLabel(),
|
2015-05-27 20:15:14 +00:00
|
|
|
FirstStart: !c.HasBeenStartedBefore,
|
2015-06-11 18:29:29 +00:00
|
|
|
LayerFolder: layerFolder,
|
|
|
|
LayerPaths: layerPaths,
|
2015-04-29 22:53:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-07-30 21:01:53 +00:00
|
|
|
// GetSize returns real size & virtual size
|
|
|
|
func (container *Container) getSize() (int64, int64) {
|
2015-04-29 22:53:35 +00:00
|
|
|
// TODO Windows
|
|
|
|
return 0, 0
|
|
|
|
}
|
|
|
|
|
2015-07-30 21:01:53 +00:00
|
|
|
// allocateNetwork is a no-op on Windows.
|
|
|
|
func (container *Container) allocateNetwork() error {
|
2015-04-29 22:53:35 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-07-30 21:01:53 +00:00
|
|
|
func (container *Container) updateNetwork() error {
|
|
|
|
return nil
|
2015-04-29 22:53:35 +00:00
|
|
|
}
|
|
|
|
|
2015-07-30 21:01:53 +00:00
|
|
|
func (container *Container) releaseNetwork() {
|
2015-04-29 22:53:35 +00:00
|
|
|
}
|
2015-05-26 16:33:55 +00:00
|
|
|
|
2015-07-30 21:01:53 +00:00
|
|
|
func (container *Container) unmountVolumes(forceSyscall bool) error {
|
2015-05-26 16:33:55 +00:00
|
|
|
return nil
|
|
|
|
}
|
2015-06-11 18:29:29 +00:00
|
|
|
|
2015-07-30 21:46:51 +00:00
|
|
|
// prepareMountPoints is a no-op on Windows
|
2015-07-16 21:14:58 +00:00
|
|
|
func (container *Container) prepareMountPoints() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-07-30 21:46:51 +00:00
|
|
|
// removeMountPoints is a no-op on Windows.
|
2015-06-12 13:25:32 +00:00
|
|
|
func (container *Container) removeMountPoints(_ bool) error {
|
2015-07-16 21:14:58 +00:00
|
|
|
return nil
|
|
|
|
}
|