mirror of https://github.com/docker/docker-py.git
Merge pull request #767 from docker/group_add_support
Support group_add param in host config
This commit is contained in:
commit
ee7292a463
|
|
@ -449,7 +449,7 @@ def create_host_config(
|
||||||
restart_policy=None, cap_add=None, cap_drop=None, devices=None,
|
restart_policy=None, cap_add=None, cap_drop=None, devices=None,
|
||||||
extra_hosts=None, read_only=None, pid_mode=None, ipc_mode=None,
|
extra_hosts=None, read_only=None, pid_mode=None, ipc_mode=None,
|
||||||
security_opt=None, ulimits=None, log_config=None, mem_limit=None,
|
security_opt=None, ulimits=None, log_config=None, mem_limit=None,
|
||||||
memswap_limit=None, cgroup_parent=None, version=None
|
memswap_limit=None, cgroup_parent=None, group_add=None, version=None
|
||||||
):
|
):
|
||||||
host_config = {}
|
host_config = {}
|
||||||
|
|
||||||
|
|
@ -509,6 +509,13 @@ def create_host_config(
|
||||||
if devices:
|
if devices:
|
||||||
host_config['Devices'] = parse_devices(devices)
|
host_config['Devices'] = parse_devices(devices)
|
||||||
|
|
||||||
|
if group_add:
|
||||||
|
if compare_version(version, '1.20') < 0:
|
||||||
|
raise errors.InvalidVersion(
|
||||||
|
'group_add param not supported for API version < 1.20'
|
||||||
|
)
|
||||||
|
host_config['GroupAdd'] = [str(grp) for grp in group_add]
|
||||||
|
|
||||||
if dns is not None:
|
if dns is not None:
|
||||||
host_config['Dns'] = dns
|
host_config['Dns'] = dns
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
# HostConfig object
|
# 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 could previously pass to `Client.start`.
|
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 could previously pass to `Client.start`.
|
||||||
*It is highly recommended that users pass the HostConfig in the `host_config`*
|
*It is highly recommended that users pass the HostConfig in the `host_config`*
|
||||||
*param of `Client.create_container` instead of `Client.start`*
|
*param of `Client.create_container` instead of `Client.start`*
|
||||||
|
|
||||||
|
|
@ -71,15 +72,16 @@ for example:
|
||||||
for more information.
|
for more information.
|
||||||
* lxc_conf (dict): LXC config
|
* lxc_conf (dict): LXC config
|
||||||
* publish_all_ports (bool): Whether to publish all ports to the host
|
* 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
|
* links (dict or list of tuples): either as a dictionary mapping name to alias
|
||||||
as a list of `(name, alias)` tuples
|
or as a list of `(name, alias)` tuples
|
||||||
* privileged (bool): Give extended privileges to this container
|
* privileged (bool): Give extended privileges to this container
|
||||||
* dns (list): Set custom DNS servers
|
* dns (list): Set custom DNS servers
|
||||||
* dns_search (list): DNS search domains
|
* dns_search (list): DNS search domains
|
||||||
* volumes_from (str or list): List of container names or Ids to get volumes
|
* 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
|
from. Optionally a single string joining container id's with commas
|
||||||
* network_mode (str): One of `['bridge', None, 'container:<name|id>', 'host']`
|
* network_mode (str): One of `['bridge', None, 'container:<name|id>', 'host']`
|
||||||
* restart_policy (dict): "Name" param must be one of `['on-failure', 'always']`
|
* restart_policy (dict): "Name" param must be one of
|
||||||
|
`['on-failure', 'always']`
|
||||||
* cap_add (list of str): Add kernel capabilities
|
* cap_add (list of str): Add kernel capabilities
|
||||||
* cap_drop (list of str): Drop kernel capabilities
|
* cap_drop (list of str): Drop kernel capabilities
|
||||||
* extra_hosts (dict): custom host-to-IP mappings (host:ip)
|
* extra_hosts (dict): custom host-to-IP mappings (host:ip)
|
||||||
|
|
@ -91,9 +93,14 @@ for example:
|
||||||
systems, such as SELinux.
|
systems, such as SELinux.
|
||||||
* ulimits (list): A list of dicts or `docker.utils.Ulimit` objects. A list
|
* ulimits (list): A list of dicts or `docker.utils.Ulimit` objects. A list
|
||||||
of ulimits to be set in the container.
|
of ulimits to be set in the container.
|
||||||
* log_config (`docker.utils.LogConfig` or dict): Logging configuration to container
|
* log_config (`docker.utils.LogConfig` or dict): Logging configuration to
|
||||||
* mem_limit (str or num): Maximum amount of memory container is allowed to consume. (e.g. `'1g'`)
|
container
|
||||||
* memswap_limit (str or num): Maximum amount of memory + swap a container is allowed to consume.
|
* mem_limit (str or num): Maximum amount of memory container is allowed to
|
||||||
|
consume. (e.g. `'1g'`)
|
||||||
|
* memswap_limit (str or num): Maximum amount of memory + swap a container is
|
||||||
|
allowed to consume.
|
||||||
|
* group_add (list): List of additional group names and/or IDs that the
|
||||||
|
container process will run as.
|
||||||
|
|
||||||
**Returns** (dict) HostConfig dictionary
|
**Returns** (dict) HostConfig dictionary
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue