|
1 |
| -# Using Tmpfs |
| 1 | +# Using tmpfs |
2 | 2 |
|
3 |
| -Tmpfs declaration is done with the `Client().create_container()` |
4 |
| -method by declaring the mountpoints in the `host_config` section. |
| 3 | +When creating a container, you can specify paths to be mounted with tmpfs using |
| 4 | +the `tmpfs` argument to `create_host_config`, similarly to the `--tmpfs` |
| 5 | +argument to `docker run`. |
5 | 6 |
|
6 |
| -This is available from docker 1.10. |
| 7 | +This capability is supported in Docker Engine 1.10 and up. |
7 | 8 |
|
8 |
| -You can provide a list of declarations similar to the `--tmpfs` |
9 |
| -option of the docker commandline client: |
| 9 | +`tmpfs` can be either a list or a dictionary. If it's a list, each item is a |
| 10 | +string specifying the path and (optionally) any configuration for the mount: |
10 | 11 |
|
11 | 12 | ```python
|
12 |
| -container_id = cli.create_container( |
| 13 | +client.create_container( |
13 | 14 | 'busybox', 'ls',
|
14 |
| - host_config=cli.create_host_config(tmpfs=[ |
| 15 | + host_config=client.create_host_config(tmpfs=[ |
15 | 16 | '/mnt/vol2',
|
16 | 17 | '/mnt/vol1:size=3G,uid=1000'
|
17 | 18 | ])
|
18 | 19 | )
|
19 | 20 | ```
|
20 | 21 |
|
21 |
| -You can alternatively specify tmpfs as a dict the docker remote |
22 |
| -API uses: |
| 22 | +Alternatively, if it's a dictionary, each key is a path and each value contains |
| 23 | +the mount options: |
23 | 24 |
|
24 | 25 | ```python
|
25 |
| -container_id = cli.create_container( |
| 26 | +client.create_container( |
26 | 27 | 'busybox', 'ls',
|
27 |
| - host_config=cli.create_host_config(tmpfs={ |
| 28 | + host_config=client.create_host_config(tmpfs={ |
28 | 29 | '/mnt/vol2': '',
|
29 | 30 | '/mnt/vol1': 'size=3G,uid=1000'
|
30 | 31 | })
|
|
0 commit comments