@@ -235,3 +235,51 @@ def test_connect_with_links(self):
235
235
)
236
236
237
237
self .execute (container , ['nslookup' , 'bar' ])
238
+
239
+ @requires_api_version ('1.22' )
240
+ def test_connect_with_ipv4_address (self ):
241
+ net_name , net_id = self .create_network ()
242
+
243
+ container = self .create_and_start (
244
+ host_config = self .client .create_host_config (network_mode = net_name ))
245
+
246
+ self .client .disconnect_container_from_network (container , net_name )
247
+ self .client .connect_container_to_network (
248
+ container , net_name ,
249
+ ipv4_address = '192.168.0.1' )
250
+
251
+ container_data = self .client .inspect_container (container )
252
+ self .assertEqual (
253
+ container_data ['NetworkSettings' ]['Networks' ][net_name ]
254
+ ['IPAMConfig' ]['IPv4Address' ],
255
+ '192.168.0.1' )
256
+
257
+ self .create_and_start (
258
+ name = 'docker-py-test-upstream' ,
259
+ host_config = self .client .create_host_config (network_mode = net_name ))
260
+
261
+ self .execute (container , ['nslookup' , 'bar' ])
262
+
263
+ @requires_api_version ('1.22' )
264
+ def test_connect_with_ipv6_address (self ):
265
+ net_name , net_id = self .create_network ()
266
+
267
+ container = self .create_and_start (
268
+ host_config = self .client .create_host_config (network_mode = net_name ))
269
+
270
+ self .client .disconnect_container_from_network (container , net_name )
271
+ self .client .connect_container_to_network (
272
+ container , net_name ,
273
+ ipv6_address = '2001:389::1' )
274
+
275
+ container_data = self .client .inspect_container (container )
276
+ self .assertEqual (
277
+ container_data ['NetworkSettings' ]['Networks' ][net_name ]
278
+ ['IPAMConfig' ]['IPv6Address' ],
279
+ '2001:389::1' )
280
+
281
+ self .create_and_start (
282
+ name = 'docker-py-test-upstream' ,
283
+ host_config = self .client .create_host_config (network_mode = net_name ))
284
+
285
+ self .execute (container , ['nslookup' , 'bar' ])
0 commit comments