@@ -39,8 +39,8 @@ def networks(self, names=None, ids=None, filters=None):
3939
4040 def create_network (self , name , driver = None , options = None , ipam = None ,
4141 check_duplicate = None , internal = False , labels = None ,
42- enable_ipv6 = False , attachable = None , scope = None ,
43- ingress = None ):
42+ enable_ipv4 = True , enable_ipv6 = False , attachable = None ,
43+ scope = None , ingress = None ):
4444 """
4545 Create a network. Similar to the ``docker network create``.
4646
@@ -55,6 +55,7 @@ def create_network(self, name, driver=None, options=None, ipam=None,
5555 ``False``.
5656 labels (dict): Map of labels to set on the network. Default
5757 ``None``.
58+ enable_ipv4 (bool): Enable IPv4 on the network. Default ``True``.
5859 enable_ipv6 (bool): Enable IPv6 on the network. Default ``False``.
5960 attachable (bool): If enabled, and the network is in the global
6061 scope, non-service containers on worker nodes will be able to
@@ -112,6 +113,13 @@ def create_network(self, name, driver=None, options=None, ipam=None,
112113 raise TypeError ('labels must be a dictionary' )
113114 data ["Labels" ] = labels
114115
116+ if not enable_ipv4 :
117+ if version_lt (self ._version , '1.48' ):
118+ raise InvalidVersion (
119+ 'enable_ipv4 was introduced in API 1.48'
120+ )
121+ data ['EnableIPv4' ] = False
122+
115123 if enable_ipv6 :
116124 if version_lt (self ._version , '1.23' ):
117125 raise InvalidVersion (
0 commit comments