Skip to content
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TEST_API_VERSION ?= 1.45
TEST_ENGINE_VERSION ?= 26.1
TEST_API_VERSION ?= 1.48
TEST_ENGINE_VERSION ?= 28.3

ifeq ($(OS),Windows_NT)
PLATFORM := Windows
Expand All @@ -11,7 +11,7 @@ ifeq ($(PLATFORM),Linux)
uid_args := "--build-arg uid=$(shell id -u) --build-arg gid=$(shell id -g)"
endif

SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER ?= $(shell git describe --match '[0-9]*' --dirty='.m' --always --tags 2>/dev/null | sed -r 's/-([0-9]+)/.dev\1/' | sed 's/-/+/')
SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER ?= $(shell git describe --match '[0-9]*' --dirty='.m' --tags 2>/dev/null | sed -r 's/-([0-9]+)/.dev\1/' | sed 's/-/+/')
ifeq ($(SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER),)
SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER = "0.0.0.dev0"
endif
Expand Down
12 changes: 10 additions & 2 deletions docker/api/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def networks(self, names=None, ids=None, filters=None):

def create_network(self, name, driver=None, options=None, ipam=None,
check_duplicate=None, internal=False, labels=None,
enable_ipv6=False, attachable=None, scope=None,
ingress=None):
enable_ipv4=True, enable_ipv6=False, attachable=None,
scope=None, ingress=None):
"""
Create a network. Similar to the ``docker network create``.

Expand All @@ -55,6 +55,7 @@ def create_network(self, name, driver=None, options=None, ipam=None,
``False``.
labels (dict): Map of labels to set on the network. Default
``None``.
enable_ipv4 (bool): Enable IPv4 on the network. Default ``True``.
enable_ipv6 (bool): Enable IPv6 on the network. Default ``False``.
attachable (bool): If enabled, and the network is in the global
scope, non-service containers on worker nodes will be able to
Expand Down Expand Up @@ -112,6 +113,13 @@ def create_network(self, name, driver=None, options=None, ipam=None,
raise TypeError('labels must be a dictionary')
data["Labels"] = labels

if not enable_ipv4:
if version_lt(self._version, '1.48'):
raise InvalidVersion(
'enable_ipv4 was introduced in API 1.48'
)
data['EnableIPv4'] = False

if enable_ipv6:
if version_lt(self._version, '1.23'):
raise InvalidVersion(
Expand Down
2 changes: 1 addition & 1 deletion docker/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .version import __version__

DEFAULT_DOCKER_API_VERSION = '1.45'
DEFAULT_DOCKER_API_VERSION = '1.48'
MINIMUM_DOCKER_API_VERSION = '1.24'
DEFAULT_TIMEOUT_SECONDS = 60
STREAM_HEADER_SIZE_BYTES = 8
Expand Down
9 changes: 9 additions & 0 deletions tests/integration/api_network_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,15 @@ def test_create_network_with_labels_wrong_type(self):
with pytest.raises(TypeError):
self.create_network(labels=['com.docker.py.test=label', ])

@requires_api_version('1.48')
def test_create_network_ipv4_disabled(self):
_, net_id = self.create_network(
driver='macvlan',
enable_ipv4=False
)
net = self.client.inspect_network(net_id)
assert net['EnableIPv4'] is False

@requires_api_version('1.23')
def test_create_network_ipv6_enabled(self):
_, net_id = self.create_network(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/api_container_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ def test_log_since_with_float(self):

def test_log_since_with_datetime(self):
ts = 809222400
time = datetime.datetime.utcfromtimestamp(ts)
time = datetime.datetime.fromtimestamp(ts, datetime.timezone.utc)
with mock.patch('docker.api.client.APIClient.inspect_container',
fake_inspect_container):
self.client.logs(fake_api.FAKE_CONTAINER_ID, stream=False,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def test_events(self):

def test_events_with_since_until(self):
ts = 1356048000
now = datetime.datetime.utcfromtimestamp(ts)
now = datetime.datetime.fromtimestamp(ts, datetime.timezone.utc)
since = now - datetime.timedelta(seconds=10)
until = now + datetime.timedelta(seconds=10)

Expand Down
1 change: 1 addition & 0 deletions tests/unit/fake_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ def get_fake_network_list():
"Id": FAKE_NETWORK_ID,
"Scope": "local",
"Driver": "bridge",
"EnableIPv4": True,
"EnableIPv6": False,
"Internal": False,
"IPAM": {
Expand Down