Skip to content

Commit d4d8611

Browse files
committed
Added API create/inspect option EnableIPv4
Signed-off-by: Rob Murray <[email protected]>
1 parent a23dcf4 commit d4d8611

4 files changed

Lines changed: 29 additions & 1 deletion

File tree

api/server/router/network/network_routes.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@ func (n *networkRouter) postNetworkCreate(ctx context.Context, w http.ResponseWr
212212
return libnetwork.NetworkNameError(create.Name)
213213
}
214214

215+
version := httputils.VersionFromContext(ctx)
216+
217+
// EnableIPv4 was introduced in API 1.47.
218+
if versions.LessThan(version, "1.47") {
219+
create.EnableIPv4 = nil
220+
}
221+
215222
// For a Swarm-scoped network, this call to backend.CreateNetwork is used to
216223
// validate the configuration. The network will not be created but, if the
217224
// configuration is valid, ManagerRedirectError will be returned and handled

api/swagger.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,6 +2484,11 @@ definitions:
24842484
`overlay`).
24852485
type: "string"
24862486
example: "overlay"
2487+
EnableIPv4:
2488+
description: |
2489+
Whether the network was created with IPv4 enabled.
2490+
type: "boolean"
2491+
example: true
24872492
EnableIPv6:
24882493
description: |
24892494
Whether the network was created with IPv6 enabled.
@@ -10377,6 +10382,7 @@ paths:
1037710382
Created: "2016-10-19T06:21:00.416543526Z"
1037810383
Scope: "local"
1037910384
Driver: "bridge"
10385+
EnableIPv4: true
1038010386
EnableIPv6: false
1038110387
Internal: false
1038210388
Attachable: false
@@ -10398,6 +10404,7 @@ paths:
1039810404
Created: "0001-01-01T00:00:00Z"
1039910405
Scope: "local"
1040010406
Driver: "null"
10407+
EnableIPv4: false
1040110408
EnableIPv6: false
1040210409
Internal: false
1040310410
Attachable: false
@@ -10412,6 +10419,7 @@ paths:
1041210419
Created: "0001-01-01T00:00:00Z"
1041310420
Scope: "local"
1041410421
Driver: "host"
10422+
EnableIPv4: false
1041510423
EnableIPv6: false
1041610424
Internal: false
1041710425
Attachable: false
@@ -10597,6 +10605,12 @@ paths:
1059710605
IPAM:
1059810606
description: "Optional custom IP scheme for the network."
1059910607
$ref: "#/definitions/IPAM"
10608+
EnableIPv4:
10609+
description: |
10610+
Enable IPv4 on the network.
10611+
To disable IPv4, the daemon must be started with experimental features enabled.
10612+
type: "boolean"
10613+
example: true
1060010614
EnableIPv6:
1060110615
description: "Enable IPv6 on the network."
1060210616
type: "boolean"

api/types/network/network.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type CreateRequest struct {
3333
type CreateOptions struct {
3434
Driver string // Driver is the driver-name used to create the network (e.g. `bridge`, `overlay`)
3535
Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level).
36+
EnableIPv4 *bool `json:",omitempty"` // EnableIPv4 represents whether to enable IPv4.
3637
EnableIPv6 *bool `json:",omitempty"` // EnableIPv6 represents whether to enable IPv6.
3738
IPAM *IPAM // IPAM is the network's IP Address Management.
3839
Internal bool // Internal represents if the network is used internal only.
@@ -76,7 +77,8 @@ type Inspect struct {
7677
Created time.Time // Created is the time the network created
7778
Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level)
7879
Driver string // Driver is the Driver name used to create the network (e.g. `bridge`, `overlay`)
79-
EnableIPv6 bool // EnableIPv6 represents whether to enable IPv6
80+
EnableIPv4 bool // EnableIPv4 represents whether IPv4 is enabled
81+
EnableIPv6 bool // EnableIPv6 represents whether IPv6 is enabled
8082
IPAM IPAM // IPAM is the network's IP Address Management
8183
Internal bool // Internal represents if the network is used internal only
8284
Attachable bool // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode.

docs/api/version-history.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ keywords: "API, Docker, rcli, REST, documentation"
1919

2020
* `Sysctls` in `HostConfig` (top level `--sysctl` settings) for `eth0` are no
2121
longer migrated to `DriverOpts`, as described in the changes for v1.46.
22+
* `POST /networks/create` now has an `EnableIPv4` field. Setting it to `false`
23+
disables IPv4 IPAM for the network. It can only be set to `false` if the
24+
daemon has experimental features enabled.
25+
* `GET /networks/{id}` now returns an `EnableIPv4` field showing whether the
26+
network has IPv4 IPAM enabled.
2227

2328
## v1.46 API changes
2429

0 commit comments

Comments
 (0)