mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #17513 from aidanhs/aphs-expose-ipv6-default-bridge
Expose bridge IPv6 setting to `docker network inspect`
This commit is contained in:
commit
2e6c841b82
13 changed files with 49 additions and 13 deletions
|
@ -50,6 +50,7 @@ func (cli *DockerCli) CmdNetworkCreate(args ...string) error {
|
|||
cmd.Var(flIpamOpt, []string{"-ipam-opt"}, "set IPAM driver specific options")
|
||||
|
||||
flInternal := cmd.Bool([]string{"-internal"}, false, "restricts external access to the network")
|
||||
flIPv6 := cmd.Bool([]string{"-ipv6"}, false, "enable IPv6 networking")
|
||||
|
||||
cmd.Require(flag.Exact, 1)
|
||||
err := cmd.ParseFlags(args, true)
|
||||
|
@ -77,6 +78,7 @@ func (cli *DockerCli) CmdNetworkCreate(args ...string) error {
|
|||
Options: flOpts.GetAll(),
|
||||
CheckDuplicate: true,
|
||||
Internal: *flInternal,
|
||||
EnableIPv6: *flIPv6,
|
||||
}
|
||||
|
||||
resp, err := cli.client.NetworkCreate(nc)
|
||||
|
|
|
@ -14,7 +14,7 @@ type Backend interface {
|
|||
GetNetworkByName(idName string) (libnetwork.Network, error)
|
||||
GetNetworksByID(partialID string) []libnetwork.Network
|
||||
GetAllNetworks() []libnetwork.Network
|
||||
CreateNetwork(name, driver string, ipam network.IPAM, options map[string]string, internal bool) (libnetwork.Network, error)
|
||||
CreateNetwork(name, driver string, ipam network.IPAM, options map[string]string, internal bool, enableIPv6 bool) (libnetwork.Network, error)
|
||||
ConnectContainerToNetwork(containerName, networkName string, endpointConfig *network.EndpointSettings) error
|
||||
DisconnectContainerFromNetwork(containerName string, network libnetwork.Network, force bool) error
|
||||
DeleteNetwork(name string) error
|
||||
|
|
|
@ -91,7 +91,7 @@ func (n *networkRouter) postNetworkCreate(ctx context.Context, w http.ResponseWr
|
|||
warning = fmt.Sprintf("Network with name %s (id : %s) already exists", nw.Name(), nw.ID())
|
||||
}
|
||||
|
||||
nw, err = n.backend.CreateNetwork(create.Name, create.Driver, create.IPAM, create.Options, create.Internal)
|
||||
nw, err = n.backend.CreateNetwork(create.Name, create.Driver, create.IPAM, create.Options, create.Internal, create.EnableIPv6)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -160,6 +160,8 @@ func buildNetworkResource(nw libnetwork.Network) *types.NetworkResource {
|
|||
r.ID = nw.ID()
|
||||
r.Scope = nw.Info().Scope()
|
||||
r.Driver = nw.Type()
|
||||
r.EnableIPv6 = nw.Info().IPv6Enabled()
|
||||
r.Internal = nw.Info().Internal()
|
||||
r.Options = nw.Info().DriverOptions()
|
||||
r.Containers = make(map[string]types.EndpointResource)
|
||||
buildIpamResources(r, nw)
|
||||
|
|
|
@ -1275,7 +1275,7 @@ _docker_network_connect() {
|
|||
|
||||
_docker_network_create() {
|
||||
case "$prev" in
|
||||
--aux-address|--gateway|--ip-range|--ipam-opt|--opt|-o|--subnet)
|
||||
--aux-address|--gateway|--internal|--ip-range|--ipam-opt|--ipv6|--opt|-o|--subnet)
|
||||
return
|
||||
;;
|
||||
--ipam-driver)
|
||||
|
@ -1294,7 +1294,7 @@ _docker_network_create() {
|
|||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--aux-address --driver -d --gateway --help --internal --ip-range --ipam-driver --ipam-opt --opt -o --subnet" -- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W "--aux-address --driver -d --gateway --help --internal --ip-range --ipam-driver --ipam-opt --ipv6 --opt -o --subnet" -- "$cur" ) )
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
|
|
@ -332,6 +332,7 @@ __docker_network_subcommand() {
|
|||
"($help)*--ip-range=[Allocate container ip from a sub-range]:IP/mask: " \
|
||||
"($help)--ipam-driver=[IP Address Management Driver]:driver:(default)" \
|
||||
"($help)*--ipam-opt=[Set custom IPAM plugin options]:opt=value: " \
|
||||
"($help)--ipv6[Enable IPv6 networking]" \
|
||||
"($help)*"{-o=,--opt=}"[Set driver specific options]:opt=value: " \
|
||||
"($help)*--subnet=[Subnet in CIDR format that represents a network segment]:IP/mask: " \
|
||||
"($help -)1:Network Name: " && ret=0
|
||||
|
|
|
@ -694,10 +694,8 @@ func initBridgeDriver(controller libnetwork.NetworkController, config *Config) e
|
|||
}
|
||||
// Initialize default network on "bridge" with the same name
|
||||
_, err = controller.NewNetwork("bridge", "bridge",
|
||||
libnetwork.NetworkOptionGeneric(options.Generic{
|
||||
netlabel.GenericData: netOption,
|
||||
netlabel.EnableIPv6: config.bridgeConfig.EnableIPv6,
|
||||
}),
|
||||
libnetwork.NetworkOptionEnableIPv6(config.bridgeConfig.EnableIPv6),
|
||||
libnetwork.NetworkOptionDriverOpts(netOption),
|
||||
libnetwork.NetworkOptionIpam("default", "", v4Conf, v6Conf, nil),
|
||||
libnetwork.NetworkOptionDeferIPv6Alloc(deferIPv6Alloc))
|
||||
if err != nil {
|
||||
|
|
|
@ -90,7 +90,7 @@ func (daemon *Daemon) GetAllNetworks() []libnetwork.Network {
|
|||
}
|
||||
|
||||
// CreateNetwork creates a network with the given name, driver and other optional parameters
|
||||
func (daemon *Daemon) CreateNetwork(name, driver string, ipam network.IPAM, options map[string]string, internal bool) (libnetwork.Network, error) {
|
||||
func (daemon *Daemon) CreateNetwork(name, driver string, ipam network.IPAM, netOption map[string]string, internal bool, enableIPv6 bool) (libnetwork.Network, error) {
|
||||
c := daemon.netController
|
||||
if driver == "" {
|
||||
driver = c.Config().Daemon.DefaultDriver
|
||||
|
@ -104,7 +104,8 @@ func (daemon *Daemon) CreateNetwork(name, driver string, ipam network.IPAM, opti
|
|||
}
|
||||
|
||||
nwOptions = append(nwOptions, libnetwork.NetworkOptionIpam(ipam.Driver, "", v4Conf, v6Conf, ipam.Options))
|
||||
nwOptions = append(nwOptions, libnetwork.NetworkOptionDriverOpts(options))
|
||||
nwOptions = append(nwOptions, libnetwork.NetworkOptionEnableIPv6(enableIPv6))
|
||||
nwOptions = append(nwOptions, libnetwork.NetworkOptionDriverOpts(netOption))
|
||||
if internal {
|
||||
nwOptions = append(nwOptions, libnetwork.NetworkOptionInternalNetwork())
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ parent = "smn_cli"
|
|||
--ip-range=[] Allocate container ip from a sub-range
|
||||
--ipam-driver=default IP Address Management Driver
|
||||
--ipam-opt=map[] Set custom IPAM driver specific options
|
||||
--ipv6 Enable IPv6 networking
|
||||
-o --opt=map[] Set custom driver specific options
|
||||
--subnet=[] Subnet in CIDR format that represents a network segment
|
||||
|
||||
|
@ -134,7 +135,13 @@ The following are those options and the equivalent docker daemon flags used for
|
|||
| `com.docker.network.bridge.enable_icc` | `--icc` | Enable or Disable Inter Container Connectivity |
|
||||
| `com.docker.network.bridge.host_binding_ipv4` | `--ip` | Default IP when binding container ports |
|
||||
| `com.docker.network.mtu` | `--mtu` | Set the containers network MTU |
|
||||
| `com.docker.network.enable_ipv6` | `--ipv6` | Enable IPv6 networking |
|
||||
|
||||
The following arguments can be passed to `docker network create` for any network driver.
|
||||
|
||||
| Argument | Equivalent | Description |
|
||||
|--------------|------------|------------------------------------------|
|
||||
| `--internal` | - | Restricts external access to the network |
|
||||
| `--ipv6` | `--ipv6` | Enable IPv6 networking |
|
||||
|
||||
For example, let's use `-o` or `--opt` options to specify an IP address binding when publishing ports:
|
||||
|
||||
|
|
|
@ -111,7 +111,13 @@ The following are those options and the equivalent docker daemon flags used for
|
|||
| `com.docker.network.bridge.enable_icc` | `--icc` | Enable or Disable Inter Container Connectivity |
|
||||
| `com.docker.network.bridge.host_binding_ipv4` | `--ip` | Default IP when binding container ports |
|
||||
| `com.docker.network.mtu` | `--mtu` | Set the containers network MTU |
|
||||
| `com.docker.network.enable_ipv6` | `--ipv6` | Enable IPv6 networking |
|
||||
|
||||
The following arguments can be passed to `docker network create` for any network driver.
|
||||
|
||||
| Argument | Equivalent | Description |
|
||||
|--------------|------------|------------------------------------------|
|
||||
| `--internal` | - | Restricts external access to the network |
|
||||
| `--ipv6` | `--ipv6` | Enable IPv6 networking |
|
||||
|
||||
For example, now let's use `-o` or `--opt` options to specify an IP address binding when publishing ports:
|
||||
|
||||
|
|
|
@ -84,6 +84,8 @@ func (s *DockerSuite) TestApiNetworkInspect(c *check.C) {
|
|||
nr = getNetworkResource(c, nr.ID)
|
||||
c.Assert(nr.Driver, checker.Equals, "bridge")
|
||||
c.Assert(nr.Scope, checker.Equals, "local")
|
||||
c.Assert(nr.Internal, checker.Equals, false)
|
||||
c.Assert(nr.EnableIPv6, checker.Equals, false)
|
||||
c.Assert(nr.IPAM.Driver, checker.Equals, "default")
|
||||
c.Assert(len(nr.Containers), checker.Equals, 1)
|
||||
c.Assert(nr.Containers[containerID], checker.NotNil)
|
||||
|
|
|
@ -574,18 +574,24 @@ func (s *DockerNetworkSuite) TestDockerNetworkInspectDefault(c *check.C) {
|
|||
nr := getNetworkResource(c, "none")
|
||||
c.Assert(nr.Driver, checker.Equals, "null")
|
||||
c.Assert(nr.Scope, checker.Equals, "local")
|
||||
c.Assert(nr.Internal, checker.Equals, false)
|
||||
c.Assert(nr.EnableIPv6, checker.Equals, false)
|
||||
c.Assert(nr.IPAM.Driver, checker.Equals, "default")
|
||||
c.Assert(len(nr.IPAM.Config), checker.Equals, 0)
|
||||
|
||||
nr = getNetworkResource(c, "host")
|
||||
c.Assert(nr.Driver, checker.Equals, "host")
|
||||
c.Assert(nr.Scope, checker.Equals, "local")
|
||||
c.Assert(nr.Internal, checker.Equals, false)
|
||||
c.Assert(nr.EnableIPv6, checker.Equals, false)
|
||||
c.Assert(nr.IPAM.Driver, checker.Equals, "default")
|
||||
c.Assert(len(nr.IPAM.Config), checker.Equals, 0)
|
||||
|
||||
nr = getNetworkResource(c, "bridge")
|
||||
c.Assert(nr.Driver, checker.Equals, "bridge")
|
||||
c.Assert(nr.Scope, checker.Equals, "local")
|
||||
c.Assert(nr.Internal, checker.Equals, false)
|
||||
c.Assert(nr.EnableIPv6, checker.Equals, false)
|
||||
c.Assert(nr.IPAM.Driver, checker.Equals, "default")
|
||||
c.Assert(len(nr.IPAM.Config), checker.Equals, 1)
|
||||
c.Assert(nr.IPAM.Config[0].Subnet, checker.NotNil)
|
||||
|
@ -600,6 +606,8 @@ func (s *DockerNetworkSuite) TestDockerNetworkInspectCustomUnspecified(c *check.
|
|||
nr := getNetworkResource(c, "test01")
|
||||
c.Assert(nr.Driver, checker.Equals, "bridge")
|
||||
c.Assert(nr.Scope, checker.Equals, "local")
|
||||
c.Assert(nr.Internal, checker.Equals, false)
|
||||
c.Assert(nr.EnableIPv6, checker.Equals, false)
|
||||
c.Assert(nr.IPAM.Driver, checker.Equals, "default")
|
||||
c.Assert(len(nr.IPAM.Config), checker.Equals, 1)
|
||||
c.Assert(nr.IPAM.Config[0].Subnet, checker.NotNil)
|
||||
|
@ -610,12 +618,14 @@ func (s *DockerNetworkSuite) TestDockerNetworkInspectCustomUnspecified(c *check.
|
|||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkInspectCustomSpecified(c *check.C) {
|
||||
dockerCmd(c, "network", "create", "--driver=bridge", "--subnet=172.28.0.0/16", "--ip-range=172.28.5.0/24", "--gateway=172.28.5.254", "br0")
|
||||
dockerCmd(c, "network", "create", "--driver=bridge", "--ipv6", "--subnet=172.28.0.0/16", "--ip-range=172.28.5.0/24", "--gateway=172.28.5.254", "br0")
|
||||
assertNwIsAvailable(c, "br0")
|
||||
|
||||
nr := getNetworkResource(c, "br0")
|
||||
c.Assert(nr.Driver, checker.Equals, "bridge")
|
||||
c.Assert(nr.Scope, checker.Equals, "local")
|
||||
c.Assert(nr.Internal, checker.Equals, false)
|
||||
c.Assert(nr.EnableIPv6, checker.Equals, true)
|
||||
c.Assert(nr.IPAM.Driver, checker.Equals, "default")
|
||||
c.Assert(len(nr.IPAM.Config), checker.Equals, 1)
|
||||
c.Assert(nr.IPAM.Config[0].Subnet, checker.Equals, "172.28.0.0/16")
|
||||
|
|
|
@ -297,6 +297,9 @@ func (s *DockerSuite) TestPortExposeHostBinding(c *check.C) {
|
|||
func (s *DockerSuite) TestPortBindingOnSandbox(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux, NotUserNamespace)
|
||||
dockerCmd(c, "network", "create", "--internal", "-d", "bridge", "internal-net")
|
||||
nr := getNetworkResource(c, "internal-net")
|
||||
c.Assert(nr.Internal, checker.Equals, true)
|
||||
|
||||
dockerCmd(c, "run", "--net", "internal-net", "-d", "--name", "c1",
|
||||
"-p", "8080:8080", "busybox", "nc", "-l", "-p", "8080")
|
||||
c.Assert(waitRun("c1"), check.IsNil)
|
||||
|
|
|
@ -14,6 +14,7 @@ docker-network-create - create a new network
|
|||
[**--ip-range**=*[]*]
|
||||
[**--ipam-driver**=*default*]
|
||||
[**--ipam-opt**=*map[]*]
|
||||
[**--ipv6**]
|
||||
[**-o**|**--opt**=*map[]*]
|
||||
[**--subnet**=*[]*]
|
||||
NETWORK-NAME
|
||||
|
@ -152,6 +153,9 @@ If you want to create an externally isolated `overlay` network, you can specify
|
|||
**--ipam-opt**=map[]
|
||||
Set custom IPAM driver options
|
||||
|
||||
**--ipv6**
|
||||
Enable IPv6 networking
|
||||
|
||||
**-o**, **--opt**=map[]
|
||||
Set custom driver options
|
||||
|
||||
|
|
Loading…
Reference in a new issue