Skip to content

Commit ac9ae1f

Browse files
committed
Fix containers low-level documentation examples
I realize that low-level documentation has outdated examples, so I created issue #2800 to fix that Signed-off-by: Felipe Ruhland <felipe.ruhland@gmail.com>
1 parent 0892fcf commit ac9ae1f

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

docker/api/container.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ def create_container(self, image, command=None, hostname=None, user=None,
244244
245245
.. code-block:: python
246246
247-
container_id = cli.create_container(
247+
container_id = client.api.create_container(
248248
'busybox', 'ls', ports=[1111, 2222],
249-
host_config=cli.create_host_config(port_bindings={
249+
host_config=client.api.create_host_config(port_bindings={
250250
1111: 4567,
251251
2222: None
252252
})
@@ -258,22 +258,22 @@ def create_container(self, image, command=None, hostname=None, user=None,
258258
259259
.. code-block:: python
260260
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)})
262262
263263
Or without host port assignment:
264264
265265
.. code-block:: python
266266
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',)})
268268
269269
If you wish to use UDP instead of TCP (default), you need to declare
270270
ports as such in both the config and host config:
271271
272272
.. code-block:: python
273273
274-
container_id = cli.create_container(
274+
container_id = client.api.create_container(
275275
'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={
277277
'1111/udp': 4567, 2222: None
278278
})
279279
)
@@ -283,15 +283,15 @@ def create_container(self, image, command=None, hostname=None, user=None,
283283
284284
.. code-block:: python
285285
286-
cli.create_host_config(port_bindings={
286+
client.api.create_host_config(port_bindings={
287287
1111: [1234, 4567]
288288
})
289289
290290
You can also bind multiple IPs to a single container port:
291291
292292
.. code-block:: python
293293
294-
cli.create_host_config(port_bindings={
294+
client.api.create_host_config(port_bindings={
295295
1111: [
296296
('192.168.0.100', 1234),
297297
('192.168.0.101', 1234)
@@ -307,9 +307,9 @@ def create_container(self, image, command=None, hostname=None, user=None,
307307
308308
.. code-block:: python
309309
310-
container_id = cli.create_container(
310+
container_id = client.api.create_container(
311311
'busybox', 'ls', volumes=['/mnt/vol1', '/mnt/vol2'],
312-
host_config=cli.create_host_config(binds={
312+
host_config=client.api.create_host_config(binds={
313313
'/home/user1/': {
314314
'bind': '/mnt/vol2',
315315
'mode': 'rw',
@@ -326,9 +326,9 @@ def create_container(self, image, command=None, hostname=None, user=None,
326326
327327
.. code-block:: python
328328
329-
container_id = cli.create_container(
329+
container_id = client.api.create_container(
330330
'busybox', 'ls', volumes=['/mnt/vol1', '/mnt/vol2'],
331-
host_config=cli.create_host_config(binds=[
331+
host_config=client.api.create_host_config(binds=[
332332
'/home/user1/:/mnt/vol2',
333333
'/var/www:/mnt/vol1:ro',
334334
])
@@ -346,15 +346,15 @@ def create_container(self, image, command=None, hostname=None, user=None,
346346
347347
.. code-block:: python
348348
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(
351351
ipv4_address='172.28.0.124',
352352
aliases=['foo', 'bar'],
353353
links=['container2']
354354
)
355355
})
356356
357-
ctnr = docker_client.create_container(
357+
ctnr = client.api.create_container(
358358
img, command, networking_config=networking_config
359359
)
360360
@@ -581,7 +581,7 @@ def create_host_config(self, *args, **kwargs):
581581
582582
Example:
583583
584-
>>> cli.create_host_config(privileged=True, cap_drop=['MKNOD'],
584+
>>> client.api.create_host_config(privileged=True, cap_drop=['MKNOD'],
585585
volumes_from=['nostalgic_newton'])
586586
{'CapDrop': ['MKNOD'], 'LxcConf': None, 'Privileged': True,
587587
'VolumesFrom': ['nostalgic_newton'], 'PublishAllPorts': False}
@@ -612,11 +612,11 @@ def create_networking_config(self, *args, **kwargs):
612612
613613
Example:
614614
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()
618618
})
619-
>>> container = docker_client.create_container(
619+
>>> container = client.api.create_container(
620620
img, command, networking_config=networking_config
621621
)
622622
@@ -650,7 +650,7 @@ def create_endpoint_config(self, *args, **kwargs):
650650
651651
Example:
652652
653-
>>> endpoint_config = client.create_endpoint_config(
653+
>>> endpoint_config = client.api.create_endpoint_config(
654654
aliases=['web', 'app'],
655655
links={'app_db': 'db', 'another': None},
656656
ipv4_address='132.65.0.123'
@@ -729,7 +729,7 @@ def get_archive(self, container, path, chunk_size=DEFAULT_DATA_CHUNK_SIZE,
729729
730730
>>> c = docker.APIClient()
731731
>>> 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')
733733
>>> print(stat)
734734
{'name': 'sh', 'size': 1075464, 'mode': 493,
735735
'mtime': '2018-10-01T15:37:48-07:00', 'linkTarget': ''}
@@ -916,7 +916,7 @@ def port(self, container, private_port):
916916
917917
.. code-block:: python
918918
919-
>>> cli.port('7174d6347063', 80)
919+
>>> client.api.port('7174d6347063', 80)
920920
[{'HostIp': '0.0.0.0', 'HostPort': '80'}]
921921
"""
922922
res = self._get(self._url("/containers/{0}/json", container))
@@ -1095,10 +1095,10 @@ def start(self, container, *args, **kwargs):
10951095
10961096
Example:
10971097
1098-
>>> container = cli.create_container(
1098+
>>> container = client.api.create_container(
10991099
... image='busybox:latest',
11001100
... command='/bin/sleep 30')
1101-
>>> cli.start(container=container.get('Id'))
1101+
>>> client.api.start(container=container.get('Id'))
11021102
"""
11031103
if args or kwargs:
11041104
raise errors.DeprecatedMethod(

0 commit comments

Comments
 (0)