@@ -244,9 +244,9 @@ def create_container(self, image, command=None, hostname=None, user=None,
244
244
245
245
.. code-block:: python
246
246
247
- container_id = cli .create_container(
247
+ container_id = client.api .create_container(
248
248
'busybox', 'ls', ports=[1111, 2222],
249
- host_config=cli .create_host_config(port_bindings={
249
+ host_config=client.api .create_host_config(port_bindings={
250
250
1111: 4567,
251
251
2222: None
252
252
})
@@ -258,22 +258,22 @@ def create_container(self, image, command=None, hostname=None, user=None,
258
258
259
259
.. code-block:: python
260
260
261
- cli .create_host_config(port_bindings={1111: ('127.0.0.1', 4567)})
261
+ client.api .create_host_config(port_bindings={1111: ('127.0.0.1', 4567)})
262
262
263
263
Or without host port assignment:
264
264
265
265
.. code-block:: python
266
266
267
- cli .create_host_config(port_bindings={1111: ('127.0.0.1',)})
267
+ client.api .create_host_config(port_bindings={1111: ('127.0.0.1',)})
268
268
269
269
If you wish to use UDP instead of TCP (default), you need to declare
270
270
ports as such in both the config and host config:
271
271
272
272
.. code-block:: python
273
273
274
- container_id = cli .create_container(
274
+ container_id = client.api .create_container(
275
275
'busybox', 'ls', ports=[(1111, 'udp'), 2222],
276
- host_config=cli .create_host_config(port_bindings={
276
+ host_config=client.api .create_host_config(port_bindings={
277
277
'1111/udp': 4567, 2222: None
278
278
})
279
279
)
@@ -283,15 +283,15 @@ def create_container(self, image, command=None, hostname=None, user=None,
283
283
284
284
.. code-block:: python
285
285
286
- cli .create_host_config(port_bindings={
286
+ client.api .create_host_config(port_bindings={
287
287
1111: [1234, 4567]
288
288
})
289
289
290
290
You can also bind multiple IPs to a single container port:
291
291
292
292
.. code-block:: python
293
293
294
- cli .create_host_config(port_bindings={
294
+ client.api .create_host_config(port_bindings={
295
295
1111: [
296
296
('192.168.0.100', 1234),
297
297
('192.168.0.101', 1234)
@@ -307,9 +307,9 @@ def create_container(self, image, command=None, hostname=None, user=None,
307
307
308
308
.. code-block:: python
309
309
310
- container_id = cli .create_container(
310
+ container_id = client.api .create_container(
311
311
'busybox', 'ls', volumes=['/mnt/vol1', '/mnt/vol2'],
312
- host_config=cli .create_host_config(binds={
312
+ host_config=client.api .create_host_config(binds={
313
313
'/home/user1/': {
314
314
'bind': '/mnt/vol2',
315
315
'mode': 'rw',
@@ -326,9 +326,9 @@ def create_container(self, image, command=None, hostname=None, user=None,
326
326
327
327
.. code-block:: python
328
328
329
- container_id = cli .create_container(
329
+ container_id = client.api .create_container(
330
330
'busybox', 'ls', volumes=['/mnt/vol1', '/mnt/vol2'],
331
- host_config=cli .create_host_config(binds=[
331
+ host_config=client.api .create_host_config(binds=[
332
332
'/home/user1/:/mnt/vol2',
333
333
'/var/www:/mnt/vol1:ro',
334
334
])
@@ -346,15 +346,15 @@ def create_container(self, image, command=None, hostname=None, user=None,
346
346
347
347
.. code-block:: python
348
348
349
- networking_config = docker_client .create_networking_config({
350
- 'network1': docker_client .create_endpoint_config(
349
+ networking_config = client.api .create_networking_config({
350
+ 'network1': client.api .create_endpoint_config(
351
351
ipv4_address='172.28.0.124',
352
352
aliases=['foo', 'bar'],
353
353
links=['container2']
354
354
)
355
355
})
356
356
357
- ctnr = docker_client .create_container(
357
+ ctnr = client.api .create_container(
358
358
img, command, networking_config=networking_config
359
359
)
360
360
@@ -581,7 +581,7 @@ def create_host_config(self, *args, **kwargs):
581
581
582
582
Example:
583
583
584
- >>> cli .create_host_config(privileged=True, cap_drop=['MKNOD'],
584
+ >>> client.api .create_host_config(privileged=True, cap_drop=['MKNOD'],
585
585
volumes_from=['nostalgic_newton'])
586
586
{'CapDrop': ['MKNOD'], 'LxcConf': None, 'Privileged': True,
587
587
'VolumesFrom': ['nostalgic_newton'], 'PublishAllPorts': False}
@@ -612,11 +612,11 @@ def create_networking_config(self, *args, **kwargs):
612
612
613
613
Example:
614
614
615
- >>> docker_client .create_network('network1')
616
- >>> networking_config = docker_client .create_networking_config({
617
- 'network1': docker_client .create_endpoint_config()
615
+ >>> client.api .create_network('network1')
616
+ >>> networking_config = client.api .create_networking_config({
617
+ 'network1': client.api .create_endpoint_config()
618
618
})
619
- >>> container = docker_client .create_container(
619
+ >>> container = client.api .create_container(
620
620
img, command, networking_config=networking_config
621
621
)
622
622
@@ -650,7 +650,7 @@ def create_endpoint_config(self, *args, **kwargs):
650
650
651
651
Example:
652
652
653
- >>> endpoint_config = client.create_endpoint_config(
653
+ >>> endpoint_config = client.api. create_endpoint_config(
654
654
aliases=['web', 'app'],
655
655
links={'app_db': 'db', 'another': None},
656
656
ipv4_address='132.65.0.123'
@@ -729,7 +729,7 @@ def get_archive(self, container, path, chunk_size=DEFAULT_DATA_CHUNK_SIZE,
729
729
730
730
>>> c = docker.APIClient()
731
731
>>> f = open('./sh_bin.tar', 'wb')
732
- >>> bits, stat = c.get_archive(container, '/bin/sh')
732
+ >>> bits, stat = c.api. get_archive(container, '/bin/sh')
733
733
>>> print(stat)
734
734
{'name': 'sh', 'size': 1075464, 'mode': 493,
735
735
'mtime': '2018-10-01T15:37:48-07:00', 'linkTarget': ''}
@@ -916,7 +916,7 @@ def port(self, container, private_port):
916
916
917
917
.. code-block:: python
918
918
919
- >>> cli .port('7174d6347063', 80)
919
+ >>> client.api .port('7174d6347063', 80)
920
920
[{'HostIp': '0.0.0.0', 'HostPort': '80'}]
921
921
"""
922
922
res = self ._get (self ._url ("/containers/{0}/json" , container ))
@@ -1095,10 +1095,10 @@ def start(self, container, *args, **kwargs):
1095
1095
1096
1096
Example:
1097
1097
1098
- >>> container = cli .create_container(
1098
+ >>> container = client.api .create_container(
1099
1099
... image='busybox:latest',
1100
1100
... command='/bin/sleep 30')
1101
- >>> cli .start(container=container.get('Id'))
1101
+ >>> client.api .start(container=container.get('Id'))
1102
1102
"""
1103
1103
if args or kwargs :
1104
1104
raise errors .DeprecatedMethod (
0 commit comments