Skip to content

Commit c698674

Browse files
committed
Merge pull request #808 from alasdairnicol/docs_examples
Docs examples
2 parents 51d2125 + 0c2aaac commit c698674

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

docs/api.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ To instantiate a `Client` class that will allow you to communicate with a
44
Docker daemon, simply do:
55

66
```python
7-
from docker import Client
8-
c = Client(base_url='unix://var/run/docker.sock')
7+
>>> from docker import Client
8+
>>> cli = Client(base_url='unix://var/run/docker.sock')
99
```
1010

1111
**Params**:
@@ -250,9 +250,9 @@ PASSWORD=secret
250250
The utility can be used as follows:
251251

252252
```python
253-
>> import docker.utils
254-
>> my_envs = docker.utils.parse_env_file('/path/to/file')
255-
>> docker.utils.create_container_config('1.18', '_mongodb', 'foobar', environment=my_envs)
253+
>>> import docker.utils
254+
>>> my_envs = docker.utils.parse_env_file('/path/to/file')
255+
>>> docker.utils.create_container_config('1.18', '_mongodb', 'foobar', environment=my_envs)
256256
```
257257

258258
You can now use this with 'environment' for `create_container`.
@@ -392,9 +392,9 @@ a dict containing `stat` information on the specified `path`.
392392

393393
```python
394394
>>> import docker
395-
>>> c = docker.Client()
396-
>>> ctnr = c.create_container('busybox', 'true')
397-
>>> strm, stat = c.get_archive(ctnr, '/bin/sh')
395+
>>> cli = docker.Client()
396+
>>> ctnr = cli.create_container('busybox', 'true')
397+
>>> strm, stat = cli.get_archive(ctnr, '/bin/sh')
398398
>>> print(stat)
399399
{u'linkTarget': u'', u'mode': 493, u'mtime': u'2015-09-16T12:34:23-07:00', u'name': u'sh', u'size': 962860}
400400
```

docs/boot2docker.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ You can then instantiate `docker.Client` like this:
1515
from docker.client import Client
1616
from docker.utils import kwargs_from_env
1717

18-
client = Client(**kwargs_from_env())
19-
print client.version()
18+
cli = Client(**kwargs_from_env())
19+
print cli.version()
2020
```
2121

2222
If you're encountering the following error:
@@ -33,6 +33,6 @@ from docker.utils import kwargs_from_env
3333
kwargs = kwargs_from_env()
3434
kwargs['tls'].assert_hostname = False
3535

36-
client = Client(**kwargs)
37-
print client.version()
36+
cli = Client(**kwargs)
37+
print cli.version()
3838
```

docs/host-devices.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ the devices parameter in the `host_config` param in `Client.create_container`
55
as shown below:
66

77
```python
8-
c.create_container(
9-
'busybox', 'true', host_config=docker.utils.create_host_config(devices=[
8+
cli.create_container(
9+
'busybox', 'true', host_config=cli.create_host_config(devices=[
1010
'/dev/sda:/dev/xvda:rwm'
1111
])
1212
)

docs/hostconfig.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ for example:
114114

115115
```python
116116
>>> from docker import Client
117-
>>> c = Client()
118-
>>> c.create_host_config(privileged=True, cap_drop=['MKNOD'], volumes_from=['nostalgic_newton'])
117+
>>> cli = Client()
118+
>>> cli.create_host_config(privileged=True, cap_drop=['MKNOD'], volumes_from=['nostalgic_newton'])
119119
{'CapDrop': ['MKNOD'], 'LxcConf': None, 'Privileged': True, 'VolumesFrom': ['nostalgic_newton'], 'PublishAllPorts': False}
120120
```

docs/port-bindings.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ open inside the container in the `Client().create_container()` method.
44
Bindings are declared in the `host_config` parameter.
55

66
```python
7-
container_id = c.create_container(
7+
container_id = cli.create_container(
88
'busybox', 'ls', ports=[1111, 2222],
9-
host_config=docker.utils.create_host_config(port_bindings={
9+
host_config=cli.create_host_config(port_bindings={
1010
1111: 4567,
1111
2222: None
1212
})
@@ -17,22 +17,22 @@ container_id = c.create_container(
1717
You can limit the host address on which the port will be exposed like such:
1818

1919
```python
20-
docker.utils.create_host_config(port_bindings={1111: ('127.0.0.1', 4567)})
20+
cli.create_host_config(port_bindings={1111: ('127.0.0.1', 4567)})
2121
```
2222

2323
Or without host port assignment:
2424

2525
```python
26-
docker.utils.create_host_config(port_bindings={1111: ('127.0.0.1',)})
26+
cli.create_host_config(port_bindings={1111: ('127.0.0.1',)})
2727
```
2828

2929
If you wish to use UDP instead of TCP (default), you need to declare ports
3030
as such in both the config and host config:
3131

3232
```python
33-
container_id = c.create_container(
33+
container_id = cli.create_container(
3434
'busybox', 'ls', ports=[(1111, 'udp'), 2222],
35-
host_config=docker.utils.create_host_config(port_bindings={
35+
host_config=cli.create_host_config(port_bindings={
3636
'1111/udp': 4567, 2222: None
3737
})
3838
)

docs/volumes.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ the `Client().create_container()` method, and declare mappings in the
55
`host_config` section.
66

77
```python
8-
container_id = c.create_container(
8+
container_id = cli.create_container(
99
'busybox', 'ls', volumes=['/mnt/vol1', '/mnt/vol2'],
10-
host_config=docker.utils.create_host_config(binds={
10+
host_config=cli.create_host_config(binds={
1111
'/home/user1/': {
1212
'bind': '/mnt/vol2',
1313
'mode': 'rw',
@@ -24,9 +24,9 @@ You can alternatively specify binds as a list. This code is equivalent to the
2424
example above:
2525

2626
```python
27-
container_id = c.create_container(
27+
container_id = cli.create_container(
2828
'busybox', 'ls', volumes=['/mnt/vol1', '/mnt/vol2'],
29-
host_config=docker.utils.create_host_config(binds=[
29+
host_config=cli.create_host_config(binds=[
3030
'/home/user1/:/mnt/vol2',
3131
'/var/www:/mnt/vol1:ro',
3232
])

0 commit comments

Comments
 (0)