Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.7.0 release #436

Merged
merged 7 commits into from
Dec 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 13 additions & 74 deletions docker/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def _container_config(self, image, command, hostname=None, user=None,
command = shlex.split(str(command))
if isinstance(environment, dict):
environment = [
(six.text_type('{0}={1}').format(k, v)
for k, v in environment.items())
six.text_type('{0}={1}').format(k, v)
for k, v in six.iteritems(environment)
]

if isinstance(mem_limit, six.string_types):
Expand Down Expand Up @@ -911,63 +911,7 @@ def start(self, container, binds=None, port_bindings=None, lxc_conf=None,
restart_policy=None, cap_add=None, cap_drop=None, devices=None,
extra_hosts=None):

start_config = {}

if isinstance(container, dict):
container = container.get('Id')

if isinstance(lxc_conf, dict):
formatted = []
for k, v in six.iteritems(lxc_conf):
formatted.append({'Key': k, 'Value': str(v)})
lxc_conf = formatted

if lxc_conf:
start_config['LxcConf'] = lxc_conf

if binds:
start_config['Binds'] = utils.convert_volume_binds(binds)

if port_bindings:
start_config['PortBindings'] = utils.convert_port_bindings(
port_bindings
)

if publish_all_ports:
start_config['PublishAllPorts'] = publish_all_ports

if links:
if isinstance(links, dict):
links = six.iteritems(links)

formatted_links = [
'{0}:{1}'.format(k, v) for k, v in sorted(links)
]

start_config['Links'] = formatted_links

if extra_hosts:
if isinstance(extra_hosts, dict):
extra_hosts = six.iteritems(extra_hosts)

formatted_extra_hosts = [
'{0}:{1}'.format(k, v) for k, v in sorted(extra_hosts)
]

start_config['ExtraHosts'] = formatted_extra_hosts

if privileged:
start_config['Privileged'] = privileged

if utils.compare_version('1.10', self._version) >= 0:
if dns is not None:
start_config['Dns'] = dns
if volumes_from is not None:
if isinstance(volumes_from, six.string_types):
volumes_from = volumes_from.split(',')
start_config['VolumesFrom'] = volumes_from
else:

if utils.compare_version('1.10', self._version) < 0:
if dns is not None:
raise errors.APIError(
'dns is only supported for API version >= 1.10'
Expand All @@ -976,23 +920,18 @@ def start(self, container, binds=None, port_bindings=None, lxc_conf=None,
raise errors.APIError(
'volumes_from is only supported for API version >= 1.10'
)
if dns_search:
start_config['DnsSearch'] = dns_search

if network_mode:
start_config['NetworkMode'] = network_mode

if restart_policy:
start_config['RestartPolicy'] = restart_policy

if cap_add:
start_config['CapAdd'] = cap_add

if cap_drop:
start_config['CapDrop'] = cap_drop
start_config = utils.create_host_config(
binds=binds, port_bindings=port_bindings, lxc_conf=lxc_conf,
publish_all_ports=publish_all_ports, links=links, dns=dns,
privileged=privileged, dns_search=dns_search, cap_add=cap_add,
cap_drop=cap_drop, volumes_from=volumes_from, devices=devices,
network_mode=network_mode, restart_policy=restart_policy,
extra_hosts=extra_hosts
)

if devices:
start_config['Devices'] = utils.parse_devices(devices)
if isinstance(container, dict):
container = container.get('Id')

url = self._url("/containers/{0}/start".format(container))
if not start_config:
Expand Down
27 changes: 20 additions & 7 deletions docker/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,16 @@ def create_host_config(
binds=None, port_bindings=None, lxc_conf=None,
publish_all_ports=False, links=None, privileged=False,
dns=None, dns_search=None, volumes_from=None, network_mode=None,
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
):
host_config = {
'Privileged': privileged,
'PublishAllPorts': publish_all_ports,
}
host_config = {}

if privileged:
host_config['Privileged'] = privileged

if publish_all_ports:
host_config['PublishAllPorts'] = publish_all_ports

if dns_search:
host_config['DnsSearch'] = dns_search
Expand Down Expand Up @@ -341,7 +345,14 @@ def create_host_config(
port_bindings
)

host_config['PublishAllPorts'] = publish_all_ports
if extra_hosts:
if isinstance(extra_hosts, dict):
extra_hosts = [
'{0}:{1}'.format(k, v)
for k, v in sorted(six.iteritems(extra_hosts))
]

host_config['ExtraHosts'] = extra_hosts

if links:
if isinstance(links, dict):
Expand All @@ -358,6 +369,8 @@ def create_host_config(
for k, v in six.iteritems(lxc_conf):
formatted.append({'Key': k, 'Value': str(v)})
lxc_conf = formatted
host_config['LxcConf'] = lxc_conf

if lxc_conf:
host_config['LxcConf'] = lxc_conf

return host_config
2 changes: 1 addition & 1 deletion docker/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "0.6.1-dev"
version = "0.7.0"
5 changes: 4 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ correct value (e.g `gzip`).
* nocache (bool): Don't use the cache when set to `True`
* rm (bool): Remove intermediate containers
* stream (bool): Return a blocking generator you can iterate over to retrieve
build output as it happens
build output as it happens
* timeout (int): HTTP timeout
* custom_context (bool): Optional if using `fileobj`
* encoding (str): The encoding for a stream. Set to `gzip` for compressing
Expand Down Expand Up @@ -385,6 +385,8 @@ Nearly identical to the `docker login` command, but non-interactive.
* email (str): The email for the registry account
* registry (str): URL to the registry. Ex:`https://index.docker.io/v1/`
* reauth (bool): Whether refresh existing authentication on the docker server.
* dockercfg_path (str): Use a custom path for the .dockercfg file
(default `$HOME/.dockercfg`)

**Returns** (dict): The response from the login request

Expand Down Expand Up @@ -636,6 +638,7 @@ from. Optionally a single string joining container id's with commas
`['on-failure', 'always']`
* cap_add (list of str): See note above
* cap_drop (list of str): See note above
* extra_hosts (dict): custom host-to-IP mappings (host:ip)

```python
>>> from docker import Client
Expand Down
37 changes: 37 additions & 0 deletions docs/change_log.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
Change Log
==========

0.7.0
-----

### Breaking changes

* Passing `dns` or `volumes_from` in `Client.start` with API version < 1.10
will now raise an exception (previously only triggered a warning)

### Features

* Added support for `host_config` in `Client.create_container`
* Added utility method `docker.utils.create_host_config` to help build a
proper `HostConfig` dictionary.
* Added support for the `pull` parameter in `Client.build`
* Added support for the `forcerm` parameter in `Client.build`
* Added support for `extra_hosts` in `Client.start`
* Added support for a custom `timeout` in `Client.wait`
* Added support for custom `.dockercfg` loading in `Client.login`
(`dockercfg_path` argument)

### Bugfixes

* Fixed a bug where some output wouldn't be streamed properly in streaming
chunked responses
* Fixed a bug where the `devices` param didn't recognize the proper delimiter
* `Client.login` now properly expands the `registry` URL if provided.
* Fixed a bug where unicode characters in passed for `environment` in
`create_container` would break.

### Miscellaneous

* Several unit tests and integration tests improvements.
* `Client` constructor now enforces passing the `version` parameter as a
string.
* Build context files are now ordered by filename when creating the archive
(for consistency with docker mainline behavior)

0.6.0
-----
* **This version introduces breaking changes!**
Expand Down
1 change: 1 addition & 0 deletions docs/hostconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ for example:
* 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
* extra_hosts (dict): custom host-to-IP mappings (host:ip)

**Returns** (dict) HostConfig dictionary

Expand Down
Loading