github.com/chenchun/docker@v1.3.2-0.20150629222414-20467faf132b/daemon/container_windows.go (about) 1 // +build windows 2 3 package daemon 4 5 import ( 6 "fmt" 7 "strings" 8 9 "github.com/docker/docker/daemon/execdriver" 10 "github.com/docker/docker/pkg/archive" 11 ) 12 13 // This is deliberately empty on Windows as the default path will be set by 14 // the container. Docker has no context of what the default path should be. 15 const DefaultPathEnv = "" 16 17 type Container struct { 18 CommonContainer 19 20 // Fields below here are platform specific. 21 22 // TODO Windows. Further factoring out of unused fields will be necessary. 23 24 // ---- START OF TEMPORARY DECLARATION ---- 25 // TODO Windows. Temporarily keeping fields in to assist in compilation 26 // of the daemon on Windows without affecting many other files in a single 27 // PR, thus making code review significantly harder. These lines will be 28 // removed in subsequent PRs. 29 30 AppArmorProfile string 31 // ---- END OF TEMPORARY DECLARATION ---- 32 33 } 34 35 func killProcessDirectly(container *Container) error { 36 return nil 37 } 38 39 func (container *Container) setupContainerDns() error { 40 return nil 41 } 42 43 func (container *Container) updateParentsHosts() error { 44 return nil 45 } 46 47 func (container *Container) setupLinkedContainers() ([]string, error) { 48 return nil, nil 49 } 50 51 func (container *Container) createDaemonEnvironment(linkedEnv []string) []string { 52 // On Windows, nothing to link. Just return the container environment. 53 return container.Config.Env 54 } 55 56 func (container *Container) initializeNetworking() error { 57 return nil 58 } 59 60 func (container *Container) setupWorkingDirectory() error { 61 return nil 62 } 63 64 func populateCommand(c *Container, env []string) error { 65 en := &execdriver.Network{ 66 Mtu: c.daemon.config.Mtu, 67 Interface: nil, 68 } 69 70 parts := strings.SplitN(string(c.hostConfig.NetworkMode), ":", 2) 71 switch parts[0] { 72 73 case "none": 74 case "default", "": // empty string to support existing containers 75 if !c.Config.NetworkDisabled { 76 network := c.NetworkSettings 77 en.Interface = &execdriver.NetworkInterface{ 78 MacAddress: network.MacAddress, 79 } 80 } 81 default: 82 return fmt.Errorf("invalid network mode: %s", c.hostConfig.NetworkMode) 83 } 84 85 pid := &execdriver.Pid{} 86 87 // TODO Windows. This can probably be factored out. 88 pid.HostPid = c.hostConfig.PidMode.IsHost() 89 90 // TODO Windows. Resource controls to be implemented later. 91 resources := &execdriver.Resources{} 92 93 // TODO Windows. Further refactoring required (privileged/user) 94 processConfig := execdriver.ProcessConfig{ 95 Privileged: c.hostConfig.Privileged, 96 Entrypoint: c.Path, 97 Arguments: c.Args, 98 Tty: c.Config.Tty, 99 User: c.Config.User, 100 } 101 102 processConfig.Env = env 103 104 // TODO Windows: Factor out remainder of unused fields. 105 c.command = &execdriver.Command{ 106 ID: c.ID, 107 Rootfs: c.RootfsPath(), 108 ReadonlyRootfs: c.hostConfig.ReadonlyRootfs, 109 InitPath: "/.dockerinit", 110 WorkingDir: c.Config.WorkingDir, 111 Network: en, 112 Pid: pid, 113 Resources: resources, 114 CapAdd: c.hostConfig.CapAdd, 115 CapDrop: c.hostConfig.CapDrop, 116 ProcessConfig: processConfig, 117 ProcessLabel: c.GetProcessLabel(), 118 MountLabel: c.GetMountLabel(), 119 } 120 121 return nil 122 } 123 124 // GetSize, return real size, virtual size 125 func (container *Container) GetSize() (int64, int64) { 126 // TODO Windows 127 return 0, 0 128 } 129 130 func (container *Container) AllocateNetwork() error { 131 132 // TODO Windows. This needs reworking with libnetwork. In the 133 // proof-of-concept for //build conference, the Windows daemon 134 // invoked eng.Job("allocate_interface) passing through 135 // RequestedMac. 136 137 return nil 138 } 139 140 func (container *Container) ExportRw() (archive.Archive, error) { 141 if container.IsRunning() { 142 return nil, fmt.Errorf("Cannot export a running container.") 143 } 144 // TODO Windows. Implementation (different to Linux) 145 return nil, nil 146 } 147 148 func (container *Container) ReleaseNetwork() { 149 // TODO Windows. Rework with libnetwork 150 } 151 152 func (container *Container) RestoreNetwork() error { 153 // TODO Windows. Rework with libnetwork 154 return nil 155 } 156 157 func disableAllActiveLinks(container *Container) { 158 } 159 160 func (container *Container) DisableLink(name string) { 161 } 162 163 func (container *Container) UnmountVolumes(forceSyscall bool) error { 164 return nil 165 }