mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Windows: Plumb through -b on daemon
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
4ef67b79bc
commit
e0ec0cc115
6 changed files with 22 additions and 17 deletions
|
@ -15,6 +15,7 @@ const (
|
||||||
// common across platforms.
|
// common across platforms.
|
||||||
type CommonConfig struct {
|
type CommonConfig struct {
|
||||||
AutoRestart bool
|
AutoRestart bool
|
||||||
|
Bridge bridgeConfig // Bridge holds bridge network specific configuration.
|
||||||
Context map[string][]string
|
Context map[string][]string
|
||||||
CorsHeaders string
|
CorsHeaders string
|
||||||
DisableBridge bool
|
DisableBridge bool
|
||||||
|
|
|
@ -22,8 +22,6 @@ type Config struct {
|
||||||
|
|
||||||
// Fields below here are platform specific.
|
// Fields below here are platform specific.
|
||||||
|
|
||||||
// Bridge holds bridge network specific configuration.
|
|
||||||
Bridge bridgeConfig
|
|
||||||
EnableSelinuxSupport bool
|
EnableSelinuxSupport bool
|
||||||
SocketGroup string
|
SocketGroup string
|
||||||
Ulimits map[string]*ulimit.Ulimit
|
Ulimits map[string]*ulimit.Ulimit
|
||||||
|
|
|
@ -2,6 +2,8 @@ package daemon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
flag "github.com/docker/docker/pkg/mflag"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -10,6 +12,12 @@ var (
|
||||||
defaultExec = "windows"
|
defaultExec = "windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// bridgeConfig stores all the bridge driver specific
|
||||||
|
// configuration.
|
||||||
|
type bridgeConfig struct {
|
||||||
|
VirtualSwitchName string
|
||||||
|
}
|
||||||
|
|
||||||
// Config defines the configuration of a docker daemon.
|
// Config defines the configuration of a docker daemon.
|
||||||
// These are the configuration settings that you pass
|
// These are the configuration settings that you pass
|
||||||
// to the docker daemon when you launch it with say: `docker -d -e windows`
|
// to the docker daemon when you launch it with say: `docker -d -e windows`
|
||||||
|
@ -28,6 +36,6 @@ func (config *Config) InstallFlags() {
|
||||||
// First handle install flags which are consistent cross-platform
|
// First handle install flags which are consistent cross-platform
|
||||||
config.InstallCommonFlags()
|
config.InstallCommonFlags()
|
||||||
|
|
||||||
// Then platform-specific install flags. There are none presently on Windows
|
// Then platform-specific install flags.
|
||||||
|
flag.StringVar(&config.Bridge.VirtualSwitchName, []string{"b", "-bridge"}, "", "Attach containers to a virtual switch")
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@ func populateCommand(c *Container, env []string) error {
|
||||||
network := c.NetworkSettings
|
network := c.NetworkSettings
|
||||||
en.Interface = &execdriver.NetworkInterface{
|
en.Interface = &execdriver.NetworkInterface{
|
||||||
MacAddress: network.MacAddress,
|
MacAddress: network.MacAddress,
|
||||||
|
Bridge: c.daemon.config.Bridge.VirtualSwitchName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -156,12 +157,6 @@ func (container *Container) GetSize() (int64, int64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) AllocateNetwork() error {
|
func (container *Container) AllocateNetwork() error {
|
||||||
|
|
||||||
// TODO Windows. This needs reworking with libnetwork. In the
|
|
||||||
// proof-of-concept for //build conference, the Windows daemon
|
|
||||||
// invoked eng.Job("allocate_interface) passing through
|
|
||||||
// RequestedMac.
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,11 +169,9 @@ func (container *Container) ExportRw() (archive.Archive, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) ReleaseNetwork() {
|
func (container *Container) ReleaseNetwork() {
|
||||||
// TODO Windows. Rework with libnetwork
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) RestoreNetwork() error {
|
func (container *Container) RestoreNetwork() error {
|
||||||
// TODO Windows. Rework with libnetwork
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@ import (
|
||||||
"github.com/microsoft/hcsshim"
|
"github.com/microsoft/hcsshim"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const DefaultVirtualSwitch = "Virtual Switch"
|
||||||
|
|
||||||
func (daemon *Daemon) Changes(container *Container) ([]archive.Change, error) {
|
func (daemon *Daemon) Changes(container *Container) ([]archive.Change, error) {
|
||||||
return daemon.driver.Changes(container.ID, container.ImageID)
|
return daemon.driver.Changes(container.ID, container.ImageID)
|
||||||
}
|
}
|
||||||
|
@ -125,7 +127,10 @@ func isBridgeNetworkDisabled(config *Config) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initNetworkController(config *Config) (libnetwork.NetworkController, error) {
|
func initNetworkController(config *Config) (libnetwork.NetworkController, error) {
|
||||||
// TODO Windows
|
// Set the name of the virtual switch if not specified by -b on daemon start
|
||||||
|
if config.Bridge.VirtualSwitchName == "" {
|
||||||
|
config.Bridge.VirtualSwitchName = DefaultVirtualSwitch
|
||||||
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,10 +81,6 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Network.Interface != nil {
|
if c.Network.Interface != nil {
|
||||||
|
|
||||||
// TODO Windows: Temporary
|
|
||||||
c.Network.Interface.Bridge = "Virtual Switch"
|
|
||||||
|
|
||||||
dev := device{
|
dev := device{
|
||||||
DeviceType: "Network",
|
DeviceType: "Network",
|
||||||
Connection: &networkConnection{
|
Connection: &networkConnection{
|
||||||
|
@ -101,7 +97,11 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logrus.Debugf("Virtual switch '%s', mac='%s'", c.Network.Interface.Bridge, c.Network.Interface.MacAddress)
|
||||||
|
|
||||||
cu.Devices = append(cu.Devices, dev)
|
cu.Devices = append(cu.Devices, dev)
|
||||||
|
} else {
|
||||||
|
logrus.Debugln("No network interface")
|
||||||
}
|
}
|
||||||
|
|
||||||
configurationb, err := json.Marshal(cu)
|
configurationb, err := json.Marshal(cu)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue