summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2014-12-17 11:29:30 -0800
committerJoffrey F <joffrey@docker.com>2014-12-17 11:48:39 -0800
commit5711ac4cf376cfa287703b8f1f0f870428243514 (patch)
treed9644418032cd6400885b38342e7960b67f2bdb6
parent2b5516afabb4ab2afe9b36b074abbc0e1928c6a2 (diff)
downloaddocker-py-5711ac4cf376cfa287703b8f1f0f870428243514.tar.gz
Updated documentation with HostConfig informationhost_config
-rw-r--r--docs/api.md16
-rw-r--r--docs/hostconfig.md91
-rw-r--r--mkdocs.yml2
3 files changed, 103 insertions, 6 deletions
diff --git a/docs/api.md b/docs/api.md
index f5b883a..64d9b3d 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -172,8 +172,9 @@ character, bytes are assumed as an intended unit.
`volumes_from` and `dns` arguments raise [TypeError](
https://docs.python.org/3.4/library/exceptions.html#TypeError) exception if
-they are used against v1.10 of the Docker remote API. Those arguments should be
-passed to `start()` instead.
+they are used against v1.10 and above of the Docker remote API. Those
+arguments should be passed to `start()` instead, or as part of the `host_config`
+dictionary.
**Params**:
@@ -200,7 +201,8 @@ from. Optionally a single string joining container id's with commas
* cpu_shares (int or float): CPU shares (relative weight)
* working_dir (str): Path to the working directory
* domainname (str or list): Set custom DNS search domains
-* memswap_limit:
+* memswap_limit (int):
+* host_config (dict): A [HostConfig](hostconfig.md) dictionary
**Returns** (dict): A dictionary with an image 'Id' key and a 'Warnings' key.
@@ -563,9 +565,13 @@ Similar to the `docker start` command, but doesn't support attach options. Use
`.logs()` to recover `stdout`/`stderr`.
`binds` allows to bind a directory in the host to the container. See [Using
-volumes](volumes.md) for more information. `port_bindings` exposes container
-ports to the host. See [Port bindings](port-bindings.md) for more information.
+volumes](volumes.md) for more information.
+
+`port_bindings` exposes container ports to the host.
+See [Port bindings](port-bindings.md) for more information.
+
`lxc_conf` allows to pass LXC configuration options using a dictionary.
+
`privileged` starts the container in privileged mode.
[Links](http://docs.docker.io/en/latest/use/working_with_links_names/) can be
diff --git a/docs/hostconfig.md b/docs/hostconfig.md
new file mode 100644
index 0000000..07a75b1
--- /dev/null
+++ b/docs/hostconfig.md
@@ -0,0 +1,91 @@
+# HostConfig object
+
+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`.
+
+## HostConfig helper
+
+### docker.utils.create_host_config
+
+Creates a HostConfig dictionary to be used with `Client.create_container`.
+
+`binds` allows to bind a directory in the host to the container. See [Using
+volumes](volumes.md) for more information.
+
+`port_bindings` exposes container ports to the host.
+See [Port bindings](port-bindings.md) for more information.
+
+`lxc_conf` allows to pass LXC configuration options using a dictionary.
+
+`privileged` starts the container in privileged mode.
+
+[Links](http://docs.docker.io/en/latest/use/working_with_links_names/) can be
+specified with the `links` argument. They can either be specified as a
+dictionary mapping name to alias or as a list of `(name, alias)` tuples.
+
+`dns` and `volumes_from` are only available if they are used with version v1.10
+of docker remote API. Otherwise they are ignored.
+
+`network_mode` is available since v1.11 and sets the Network mode for the
+container ('bridge': creates a new network stack for the container on the
+Docker bridge, 'none': no networking for this container, 'container:[name|id]':
+reuses another container network stack), 'host': use the host network stack
+inside the container.
+
+`restart_policy` is available since v1.2.0 and sets the RestartPolicy for how a
+container should or should not be restarted on exit. By default the policy is
+set to no meaning do not restart the container when it exits. The user may
+specify the restart policy as a dictionary for example:
+```python
+{
+ "MaximumRetryCount": 0,
+ "Name": "always"
+}
+```
+
+For always restarting the container on exit or can specify to restart the
+container to restart on failure and can limit number of restarts. For example:
+```python
+{
+ "MaximumRetryCount": 5,
+ "Name": "on-failure"
+}
+```
+
+`cap_add` and `cap_drop` are available since v1.2.0 and can be used to add or
+drop certain capabilities. The user may specify the capabilities as an array
+for example:
+```python
+[
+ "SYS_ADMIN",
+ "MKNOD"
+]
+```
+
+
+**Params**
+
+* container (str): The container to start
+* binds: Volumes to bind. See [Using volumes](volumes.md) for more information.
+* port_bindings (dict): Port bindings. See [Port bindings](port-bindings.md)
+ for more information.
+* lxc_conf (dict): LXC config
+* publish_all_ports (bool): Whether to publish all ports to the host
+* links (dict or list of tuples): either as a dictionary mapping name to alias or
+ as a list of `(name, alias)` tuples
+* privileged (bool): Give extended privileges to this container
+* dns (list): Set custom DNS servers
+* dns_search (list): DNS search domains
+* volumes_from (str or list): List of container names or Ids to get volumes
+ from. Optionally a single string joining container id's with commas
+* network_mode (str): One of `['bridge', None, 'container:<name|id>', 'host']`
+* restart_policy (dict): "Name" param must be one of `['on-failure', 'always']`
+* cap_add (list of str): Add kernel capabilities
+* cap_drop (list of str): Drop kernel capabilities
+
+**Returns** (dict) HostConfig dictionary
+
+```python
+>>> from docker.utils import create_host_config
+>>> create_host_config(privileged=True, cap_drop=['MKNOD'], volumes_from=['nostalgic_newton'])
+{'CapDrop': ['MKNOD'], 'LxcConf': None, 'Privileged': True, 'VolumesFrom': ['nostalgic_newton'], 'PublishAllPorts': False}
+``` \ No newline at end of file
diff --git a/mkdocs.yml b/mkdocs.yml
index 3f2eda3..c78588d 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -1,7 +1,7 @@
site_name: docker-py Documentation
site_description: An API client for Docker written in Python
site_favicon: favicon_whale.png
-# site_url: docker-py.readthedocs.org
+site_url: docker-py.readthedocs.org
repo_url: https://github.com/docker/docker-py/
theme: readthedocs
pages: