@@ -38,7 +38,7 @@ def networks(self, names=None, ids=None):
38
38
@minimum_version ('1.21' )
39
39
def create_network (self , name , driver = None , options = None , ipam = None ,
40
40
check_duplicate = None , internal = False , labels = None ,
41
- enable_ipv6 = False ):
41
+ enable_ipv6 = False , attachable = None ):
42
42
"""
43
43
Create a network. Similar to the ``docker network create``.
44
44
@@ -54,6 +54,9 @@ def create_network(self, name, driver=None, options=None, ipam=None,
54
54
labels (dict): Map of labels to set on the network. Default
55
55
``None``.
56
56
enable_ipv6 (bool): Enable IPv6 on the network. Default ``False``.
57
+ attachable (bool): If enabled, and the network is in the global
58
+ scope, non-service containers on worker nodes will be able to
59
+ connect to the network.
57
60
58
61
Returns:
59
62
(dict): The created network reference object
@@ -91,7 +94,7 @@ def create_network(self, name, driver=None, options=None, ipam=None,
91
94
'Driver' : driver ,
92
95
'Options' : options ,
93
96
'IPAM' : ipam ,
94
- 'CheckDuplicate' : check_duplicate
97
+ 'CheckDuplicate' : check_duplicate ,
95
98
}
96
99
97
100
if labels is not None :
@@ -116,6 +119,12 @@ def create_network(self, name, driver=None, options=None, ipam=None,
116
119
'supported in API version < 1.22' )
117
120
data ['Internal' ] = True
118
121
122
+ if attachable is not None
123
+ if version_lt (self ._version , '1.24' ):
124
+ raise InvalidVersion ('Attachable is not '
125
+ 'supported in API version < 1.24' )
126
+ data ['Attachable' ] = attachable
127
+
119
128
url = self ._url ("/networks/create" )
120
129
res = self ._post_json (url , data = data )
121
130
return self ._result (res , json = True )
0 commit comments