summaryrefslogtreecommitdiff
path: root/docs/volumes.md
blob: 04273d805d6058bcd02565ba48357f0bce911457 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Using volumes

Volume declaration is done in two parts.  Provide a list of mountpoints to
the `Client().create_container()` method, and declare mappings in the
`host_config` section.

```python
container_id = cli.create_container(
    'busybox', 'ls', volumes=['/mnt/vol1', '/mnt/vol2'],
    host_config=cli.create_host_config(binds={
        '/home/user1/': {
            'bind': '/mnt/vol2',
            'mode': 'rw',
        },
        '/var/www': {
            'bind': '/mnt/vol1',
            'mode': 'ro',
        }
    })
)
```

You can alternatively specify binds as a list. This code is equivalent to the
example above:

```python
container_id = cli.create_container(
    'busybox', 'ls', volumes=['/mnt/vol1', '/mnt/vol2'],
    host_config=cli.create_host_config(binds=[
        '/home/user1/:/mnt/vol2',
        '/var/www:/mnt/vol1:ro',
    ])
)
```