Skip to content

Commit 9b166ee

Browse files
committed
Merge pull request #436 from docker/0.7.0-release
0.7.0 release
2 parents 53beba7 + 2218dba commit 9b166ee

File tree

9 files changed

+132
-107
lines changed

9 files changed

+132
-107
lines changed

docker/client.py

Lines changed: 13 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ def _container_config(self, image, command, hostname=None, user=None,
115115
command = shlex.split(str(command))
116116
if isinstance(environment, dict):
117117
environment = [
118-
(six.text_type('{0}={1}').format(k, v)
119-
for k, v in environment.items())
118+
six.text_type('{0}={1}').format(k, v)
119+
for k, v in six.iteritems(environment)
120120
]
121121

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

914-
start_config = {}
915-
916-
if isinstance(container, dict):
917-
container = container.get('Id')
918-
919-
if isinstance(lxc_conf, dict):
920-
formatted = []
921-
for k, v in six.iteritems(lxc_conf):
922-
formatted.append({'Key': k, 'Value': str(v)})
923-
lxc_conf = formatted
924-
925-
if lxc_conf:
926-
start_config['LxcConf'] = lxc_conf
927-
928-
if binds:
929-
start_config['Binds'] = utils.convert_volume_binds(binds)
930-
931-
if port_bindings:
932-
start_config['PortBindings'] = utils.convert_port_bindings(
933-
port_bindings
934-
)
935-
936-
if publish_all_ports:
937-
start_config['PublishAllPorts'] = publish_all_ports
938-
939-
if links:
940-
if isinstance(links, dict):
941-
links = six.iteritems(links)
942-
943-
formatted_links = [
944-
'{0}:{1}'.format(k, v) for k, v in sorted(links)
945-
]
946-
947-
start_config['Links'] = formatted_links
948-
949-
if extra_hosts:
950-
if isinstance(extra_hosts, dict):
951-
extra_hosts = six.iteritems(extra_hosts)
952-
953-
formatted_extra_hosts = [
954-
'{0}:{1}'.format(k, v) for k, v in sorted(extra_hosts)
955-
]
956-
957-
start_config['ExtraHosts'] = formatted_extra_hosts
958-
959-
if privileged:
960-
start_config['Privileged'] = privileged
961-
962-
if utils.compare_version('1.10', self._version) >= 0:
963-
if dns is not None:
964-
start_config['Dns'] = dns
965-
if volumes_from is not None:
966-
if isinstance(volumes_from, six.string_types):
967-
volumes_from = volumes_from.split(',')
968-
start_config['VolumesFrom'] = volumes_from
969-
else:
970-
914+
if utils.compare_version('1.10', self._version) < 0:
971915
if dns is not None:
972916
raise errors.APIError(
973917
'dns is only supported for API version >= 1.10'
@@ -976,23 +920,18 @@ def start(self, container, binds=None, port_bindings=None, lxc_conf=None,
976920
raise errors.APIError(
977921
'volumes_from is only supported for API version >= 1.10'
978922
)
979-
if dns_search:
980-
start_config['DnsSearch'] = dns_search
981-
982-
if network_mode:
983-
start_config['NetworkMode'] = network_mode
984-
985-
if restart_policy:
986-
start_config['RestartPolicy'] = restart_policy
987-
988-
if cap_add:
989-
start_config['CapAdd'] = cap_add
990923

991-
if cap_drop:
992-
start_config['CapDrop'] = cap_drop
924+
start_config = utils.create_host_config(
925+
binds=binds, port_bindings=port_bindings, lxc_conf=lxc_conf,
926+
publish_all_ports=publish_all_ports, links=links, dns=dns,
927+
privileged=privileged, dns_search=dns_search, cap_add=cap_add,
928+
cap_drop=cap_drop, volumes_from=volumes_from, devices=devices,
929+
network_mode=network_mode, restart_policy=restart_policy,
930+
extra_hosts=extra_hosts
931+
)
993932

994-
if devices:
995-
start_config['Devices'] = utils.parse_devices(devices)
933+
if isinstance(container, dict):
934+
container = container.get('Id')
996935

997936
url = self._url("/containers/{0}/start".format(container))
998937
if not start_config:

docker/utils/utils.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,16 @@ def create_host_config(
300300
binds=None, port_bindings=None, lxc_conf=None,
301301
publish_all_ports=False, links=None, privileged=False,
302302
dns=None, dns_search=None, volumes_from=None, network_mode=None,
303-
restart_policy=None, cap_add=None, cap_drop=None, devices=None
303+
restart_policy=None, cap_add=None, cap_drop=None, devices=None,
304+
extra_hosts=None
304305
):
305-
host_config = {
306-
'Privileged': privileged,
307-
'PublishAllPorts': publish_all_ports,
308-
}
306+
host_config = {}
307+
308+
if privileged:
309+
host_config['Privileged'] = privileged
310+
311+
if publish_all_ports:
312+
host_config['PublishAllPorts'] = publish_all_ports
309313

310314
if dns_search:
311315
host_config['DnsSearch'] = dns_search
@@ -341,7 +345,14 @@ def create_host_config(
341345
port_bindings
342346
)
343347

344-
host_config['PublishAllPorts'] = publish_all_ports
348+
if extra_hosts:
349+
if isinstance(extra_hosts, dict):
350+
extra_hosts = [
351+
'{0}:{1}'.format(k, v)
352+
for k, v in sorted(six.iteritems(extra_hosts))
353+
]
354+
355+
host_config['ExtraHosts'] = extra_hosts
345356

346357
if links:
347358
if isinstance(links, dict):
@@ -358,6 +369,8 @@ def create_host_config(
358369
for k, v in six.iteritems(lxc_conf):
359370
formatted.append({'Key': k, 'Value': str(v)})
360371
lxc_conf = formatted
361-
host_config['LxcConf'] = lxc_conf
372+
373+
if lxc_conf:
374+
host_config['LxcConf'] = lxc_conf
362375

363376
return host_config

docker/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "0.6.1-dev"
1+
version = "0.7.0"

docs/api.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ correct value (e.g `gzip`).
5454
* nocache (bool): Don't use the cache when set to `True`
5555
* rm (bool): Remove intermediate containers
5656
* stream (bool): Return a blocking generator you can iterate over to retrieve
57-
build output as it happens
57+
build output as it happens
5858
* timeout (int): HTTP timeout
5959
* custom_context (bool): Optional if using `fileobj`
6060
* encoding (str): The encoding for a stream. Set to `gzip` for compressing
@@ -385,6 +385,8 @@ Nearly identical to the `docker login` command, but non-interactive.
385385
* email (str): The email for the registry account
386386
* registry (str): URL to the registry. Ex:`https://index.docker.io/v1/`
387387
* reauth (bool): Whether refresh existing authentication on the docker server.
388+
* dockercfg_path (str): Use a custom path for the .dockercfg file
389+
(default `$HOME/.dockercfg`)
388390

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

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

640643
```python
641644
>>> from docker import Client

docs/change_log.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,43 @@
11
Change Log
22
==========
33

4+
0.7.0
5+
-----
6+
7+
### Breaking changes
8+
9+
* Passing `dns` or `volumes_from` in `Client.start` with API version < 1.10
10+
will now raise an exception (previously only triggered a warning)
11+
12+
### Features
13+
14+
* Added support for `host_config` in `Client.create_container`
15+
* Added utility method `docker.utils.create_host_config` to help build a
16+
proper `HostConfig` dictionary.
17+
* Added support for the `pull` parameter in `Client.build`
18+
* Added support for the `forcerm` parameter in `Client.build`
19+
* Added support for `extra_hosts` in `Client.start`
20+
* Added support for a custom `timeout` in `Client.wait`
21+
* Added support for custom `.dockercfg` loading in `Client.login`
22+
(`dockercfg_path` argument)
23+
24+
### Bugfixes
25+
26+
* Fixed a bug where some output wouldn't be streamed properly in streaming
27+
chunked responses
28+
* Fixed a bug where the `devices` param didn't recognize the proper delimiter
29+
* `Client.login` now properly expands the `registry` URL if provided.
30+
* Fixed a bug where unicode characters in passed for `environment` in
31+
`create_container` would break.
32+
33+
### Miscellaneous
34+
35+
* Several unit tests and integration tests improvements.
36+
* `Client` constructor now enforces passing the `version` parameter as a
37+
string.
38+
* Build context files are now ordered by filename when creating the archive
39+
(for consistency with docker mainline behavior)
40+
441
0.6.0
542
-----
643
* **This version introduces breaking changes!**

docs/hostconfig.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ for example:
8181
* restart_policy (dict): "Name" param must be one of `['on-failure', 'always']`
8282
* cap_add (list of str): Add kernel capabilities
8383
* cap_drop (list of str): Drop kernel capabilities
84+
* extra_hosts (dict): custom host-to-IP mappings (host:ip)
8485

8586
**Returns** (dict) HostConfig dictionary
8687

0 commit comments

Comments
 (0)