github.com/mheon/docker@v0.11.2-0.20150922122814-44f47903a831/daemon/container_windows.go (about) 1 // +build windows 2 3 package daemon 4 5 import ( 6 "strings" 7 8 "github.com/docker/docker/daemon/execdriver" 9 derr "github.com/docker/docker/errors" 10 ) 11 12 // DefaultPathEnv is deliberately empty on Windows as the default path will be set by 13 // the container. Docker has no context of what the default path should be. 14 const DefaultPathEnv = "" 15 16 // Container holds fields specific to the Windows implementation. See 17 // CommonContainer for standard fields common to all containers. 18 type Container struct { 19 CommonContainer 20 21 // Fields below here are platform specific. 22 } 23 24 func killProcessDirectly(container *Container) error { 25 return nil 26 } 27 28 func (container *Container) setupLinkedContainers() ([]string, error) { 29 return nil, nil 30 } 31 32 func (container *Container) createDaemonEnvironment(linkedEnv []string) []string { 33 // On Windows, nothing to link. Just return the container environment. 34 return container.Config.Env 35 } 36 37 func (container *Container) initializeNetworking() error { 38 return nil 39 } 40 41 func (container *Container) setupWorkingDirectory() error { 42 return nil 43 } 44 45 func populateCommand(c *Container, env []string) error { 46 en := &execdriver.Network{ 47 Interface: nil, 48 } 49 50 parts := strings.SplitN(string(c.hostConfig.NetworkMode), ":", 2) 51 switch parts[0] { 52 case "none": 53 case "default", "": // empty string to support existing containers 54 if !c.Config.NetworkDisabled { 55 en.Interface = &execdriver.NetworkInterface{ 56 MacAddress: c.Config.MacAddress, 57 Bridge: c.daemon.configStore.Bridge.VirtualSwitchName, 58 PortBindings: c.hostConfig.PortBindings, 59 60 // TODO Windows. Include IPAddress. There already is a 61 // property IPAddress on execDrive.CommonNetworkInterface, 62 // but there is no CLI option in docker to pass through 63 // an IPAddress on docker run. 64 } 65 } 66 default: 67 return derr.ErrorCodeInvalidNetworkMode.WithArgs(c.hostConfig.NetworkMode) 68 } 69 70 pid := &execdriver.Pid{} 71 72 // TODO Windows. This can probably be factored out. 73 pid.HostPid = c.hostConfig.PidMode.IsHost() 74 75 // TODO Windows. Resource controls to be implemented later. 76 resources := &execdriver.Resources{} 77 78 // TODO Windows. Further refactoring required (privileged/user) 79 processConfig := execdriver.ProcessConfig{ 80 Privileged: c.hostConfig.Privileged, 81 Entrypoint: c.Path, 82 Arguments: c.Args, 83 Tty: c.Config.Tty, 84 User: c.Config.User, 85 ConsoleSize: c.hostConfig.ConsoleSize, 86 } 87 88 processConfig.Env = env 89 90 var layerPaths []string 91 img, err := c.daemon.graph.Get(c.ImageID) 92 if err != nil { 93 return derr.ErrorCodeGetGraph.WithArgs(c.ImageID, err) 94 } 95 for i := img; i != nil && err == nil; i, err = c.daemon.graph.GetParent(i) { 96 lp, err := c.daemon.driver.Get(i.ID, "") 97 if err != nil { 98 return derr.ErrorCodeGetLayer.WithArgs(c.daemon.driver.String(), i.ID, err) 99 } 100 layerPaths = append(layerPaths, lp) 101 err = c.daemon.driver.Put(i.ID) 102 if err != nil { 103 return derr.ErrorCodePutLayer.WithArgs(c.daemon.driver.String(), i.ID, err) 104 } 105 } 106 m, err := c.daemon.driver.GetMetadata(c.ID) 107 if err != nil { 108 return derr.ErrorCodeGetLayerMetadata.WithArgs(err) 109 } 110 layerFolder := m["dir"] 111 112 // TODO Windows: Factor out remainder of unused fields. 113 c.command = &execdriver.Command{ 114 ID: c.ID, 115 Rootfs: c.rootfsPath(), 116 ReadonlyRootfs: c.hostConfig.ReadonlyRootfs, 117 InitPath: "/.dockerinit", 118 WorkingDir: c.Config.WorkingDir, 119 Network: en, 120 Pid: pid, 121 Resources: resources, 122 CapAdd: c.hostConfig.CapAdd.Slice(), 123 CapDrop: c.hostConfig.CapDrop.Slice(), 124 ProcessConfig: processConfig, 125 ProcessLabel: c.getProcessLabel(), 126 MountLabel: c.getMountLabel(), 127 FirstStart: !c.HasBeenStartedBefore, 128 LayerFolder: layerFolder, 129 LayerPaths: layerPaths, 130 } 131 132 return nil 133 } 134 135 // GetSize returns real size & virtual size 136 func (container *Container) getSize() (int64, int64) { 137 // TODO Windows 138 return 0, 0 139 } 140 141 // setNetworkNamespaceKey is a no-op on Windows. 142 func (container *Container) setNetworkNamespaceKey(pid int) error { 143 return nil 144 } 145 146 // allocateNetwork is a no-op on Windows. 147 func (container *Container) allocateNetwork() error { 148 return nil 149 } 150 151 func (container *Container) updateNetwork() error { 152 return nil 153 } 154 155 func (container *Container) releaseNetwork() { 156 } 157 158 func (container *Container) unmountVolumes(forceSyscall bool) error { 159 return nil 160 } 161 162 // prepareMountPoints is a no-op on Windows 163 func (container *Container) prepareMountPoints() error { 164 return nil 165 } 166 167 // removeMountPoints is a no-op on Windows. 168 func (container *Container) removeMountPoints(_ bool) error { 169 return nil 170 }