You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Docker Remote API introduced [support for HostConfig in version 1.15](http://docs.docker.com/reference/api/docker_remote_api_v1.15/#create-a-container). This object contains all the parameters you can pass to `Client.start`.
4
+
5
+
## HostConfig helper
6
+
7
+
### docker.utils.create_host_config
8
+
9
+
Creates a HostConfig dictionary to be used with `Client.create_container`.
10
+
11
+
`binds` allows to bind a directory in the host to the container. See [Using
12
+
volumes](volumes.md) for more information.
13
+
14
+
`port_bindings` exposes container ports to the host.
15
+
See [Port bindings](port-bindings.md) for more information.
16
+
17
+
`lxc_conf` allows to pass LXC configuration options using a dictionary.
18
+
19
+
`privileged` starts the container in privileged mode.
20
+
21
+
[Links](http://docs.docker.io/en/latest/use/working_with_links_names/) can be
22
+
specified with the `links` argument. They can either be specified as a
23
+
dictionary mapping name to alias or as a list of `(name, alias)` tuples.
24
+
25
+
`dns` and `volumes_from` are only available if they are used with version v1.10
26
+
of docker remote API. Otherwise they are ignored.
27
+
28
+
`network_mode` is available since v1.11 and sets the Network mode for the
29
+
container ('bridge': creates a new network stack for the container on the
30
+
Docker bridge, 'none': no networking for this container, 'container:[name|id]':
31
+
reuses another container network stack), 'host': use the host network stack
32
+
inside the container.
33
+
34
+
`restart_policy` is available since v1.2.0 and sets the RestartPolicy for how a
35
+
container should or should not be restarted on exit. By default the policy is
36
+
set to no meaning do not restart the container when it exits. The user may
37
+
specify the restart policy as a dictionary for example:
38
+
```python
39
+
{
40
+
"MaximumRetryCount": 0,
41
+
"Name": "always"
42
+
}
43
+
```
44
+
45
+
For always restarting the container on exit or can specify to restart the
46
+
container to restart on failure and can limit number of restarts. For example:
47
+
```python
48
+
{
49
+
"MaximumRetryCount": 5,
50
+
"Name": "on-failure"
51
+
}
52
+
```
53
+
54
+
`cap_add` and `cap_drop` are available since v1.2.0 and can be used to add or
55
+
drop certain capabilities. The user may specify the capabilities as an array
56
+
for example:
57
+
```python
58
+
[
59
+
"SYS_ADMIN",
60
+
"MKNOD"
61
+
]
62
+
```
63
+
64
+
65
+
**Params**
66
+
67
+
* container (str): The container to start
68
+
* binds: Volumes to bind. See [Using volumes](volumes.md) for more information.
69
+
* port_bindings (dict): Port bindings. See [Port bindings](port-bindings.md)
70
+
for more information.
71
+
* lxc_conf (dict): LXC config
72
+
* publish_all_ports (bool): Whether to publish all ports to the host
73
+
* links (dict or list of tuples): either as a dictionary mapping name to alias or
74
+
as a list of `(name, alias)` tuples
75
+
* privileged (bool): Give extended privileges to this container
76
+
* dns (list): Set custom DNS servers
77
+
* dns_search (list): DNS search domains
78
+
* volumes_from (str or list): List of container names or Ids to get volumes
79
+
from. Optionally a single string joining container id's with commas
80
+
* network_mode (str): One of `['bridge', None, 'container:<name|id>', 'host']`
81
+
* restart_policy (dict): "Name" param must be one of `['on-failure', 'always']`
82
+
* cap_add (list of str): Add kernel capabilities
83
+
* cap_drop (list of str): Drop kernel capabilities
0 commit comments