Skip to content

Commit 5d42ab8

Browse files
authored
Merge pull request #2331 from docker/4.0.0-release
4.0.0 release
2 parents a4c251d + 5de5af1 commit 5d42ab8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+918
-249
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ matrix:
44
include:
55
- python: 2.7
66
env: TOXENV=py27
7-
- python: 3.4
8-
env: TOXENV=py34
97
- python: 3.5
108
env: TOXENV=py35
119
- python: 3.6

Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def buildImages = { ->
2424
imageNamePy2 = "${imageNameBase}:py2-${gitCommit()}"
2525
imageNamePy3 = "${imageNameBase}:py3-${gitCommit()}"
2626

27-
buildImage(imageNamePy2, ".", "py2.7")
28-
buildImage(imageNamePy3, "-f Dockerfile-py3 .", "py3.6")
27+
buildImage(imageNamePy2, "-f tests/Dockerfile --build-arg PYTHON_VERSION=2.7 .", "py2.7")
28+
buildImage(imageNamePy3, "-f tests/Dockerfile --build-arg PYTHON_VERSION=3.6 .", "py3.6")
2929
}
3030
}
3131
}

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ include LICENSE
66
recursive-include tests *.py
77
recursive-include tests/unit/testdata *
88
recursive-include tests/integration/testdata *
9+
recursive-include tests/gpg-keys *

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ clean:
88

99
.PHONY: build
1010
build:
11-
docker build -t docker-sdk-python .
11+
docker build -t docker-sdk-python -f tests/Dockerfile --build-arg PYTHON_VERSION=2.7 .
1212

1313
.PHONY: build-py3
1414
build-py3:
15-
docker build -t docker-sdk-python3 -f Dockerfile-py3 .
15+
docker build -t docker-sdk-python3 -f tests/Dockerfile .
1616

1717
.PHONY: build-docs
1818
build-docs:
@@ -39,10 +39,10 @@ integration-test: build
3939

4040
.PHONY: integration-test-py3
4141
integration-test-py3: build-py3
42-
docker run -t --rm -v /var/run/docker.sock:/var/run/docker.sock docker-sdk-python3 py.test tests/integration/${file}
42+
docker run -t --rm -v /var/run/docker.sock:/var/run/docker.sock docker-sdk-python3 py.test -v tests/integration/${file}
4343

4444
TEST_API_VERSION ?= 1.35
45-
TEST_ENGINE_VERSION ?= 17.12.0-ce
45+
TEST_ENGINE_VERSION ?= 18.09.5
4646

4747
.PHONY: setup-network
4848
setup-network:

docker/api/build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
2020
decode=False, buildargs=None, gzip=False, shmsize=None,
2121
labels=None, cache_from=None, target=None, network_mode=None,
2222
squash=None, extra_hosts=None, platform=None, isolation=None,
23-
use_config_proxy=False):
23+
use_config_proxy=True):
2424
"""
2525
Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
2626
needs to be set. ``path`` can be a local path (to a directory
@@ -121,6 +121,7 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
121121
remote = context = None
122122
headers = {}
123123
container_limits = container_limits or {}
124+
buildargs = buildargs or {}
124125
if path is None and fileobj is None:
125126
raise TypeError("Either path or fileobj needs to be provided.")
126127
if gzip and encoding is not None:

docker/api/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class APIClient(
8282
base_url (str): URL to the Docker server. For example,
8383
``unix:///var/run/docker.sock`` or ``tcp://127.0.0.1:1234``.
8484
version (str): The version of the API to use. Set to ``auto`` to
85-
automatically detect the server's version. Default: ``1.30``
85+
automatically detect the server's version. Default: ``1.35``
8686
timeout (int): Default timeout for API calls, in seconds.
8787
tls (bool or :py:class:`~docker.tls.TLSConfig`): Enable TLS. Pass
8888
``True`` to enable it with default options, or pass a

docker/api/container.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import six
21
from datetime import datetime
32

3+
import six
4+
45
from .. import errors
56
from .. import utils
67
from ..constants import DEFAULT_DATA_CHUNK_SIZE
7-
from ..types import (
8-
CancellableStream, ContainerConfig, EndpointConfig, HostConfig,
9-
NetworkingConfig
10-
)
8+
from ..types import CancellableStream
9+
from ..types import ContainerConfig
10+
from ..types import EndpointConfig
11+
from ..types import HostConfig
12+
from ..types import NetworkingConfig
1113

1214

1315
class ContainerApiMixin(object):
@@ -222,7 +224,7 @@ def create_container(self, image, command=None, hostname=None, user=None,
222224
mac_address=None, labels=None, stop_signal=None,
223225
networking_config=None, healthcheck=None,
224226
stop_timeout=None, runtime=None,
225-
use_config_proxy=False):
227+
use_config_proxy=True):
226228
"""
227229
Creates a container. Parameters are similar to those for the ``docker
228230
run`` command except it doesn't support the attach options (``-a``).
@@ -414,7 +416,7 @@ def create_container(self, image, command=None, hostname=None, user=None,
414416
if use_config_proxy:
415417
environment = self._proxy_configs.inject_proxy_environment(
416418
environment
417-
)
419+
) or None
418420

419421
config = self.create_container_config(
420422
image, command, hostname, user, detach, stdin_open, tty,
@@ -487,7 +489,6 @@ def create_host_config(self, *args, **kwargs):
487489
IDs that the container process will run as.
488490
init (bool): Run an init inside the container that forwards
489491
signals and reaps processes
490-
init_path (str): Path to the docker-init binary
491492
ipc_mode (str): Set the IPC mode for the container.
492493
isolation (str): Isolation technology to use. Default: ``None``.
493494
links (dict): Mapping of links using the
@@ -512,7 +513,7 @@ def create_host_config(self, *args, **kwargs):
512513
network_mode (str): One of:
513514
514515
- ``bridge`` Create a new network stack for the container on
515-
on the bridge network.
516+
the bridge network.
516517
- ``none`` No networking for this container.
517518
- ``container:<name|id>`` Reuse another container's network
518519
stack.
@@ -915,9 +916,10 @@ def port(self, container, private_port):
915916
if '/' in private_port:
916917
return port_settings.get(private_port)
917918

918-
h_ports = port_settings.get(private_port + '/tcp')
919-
if h_ports is None:
920-
h_ports = port_settings.get(private_port + '/udp')
919+
for protocol in ['tcp', 'udp', 'sctp']:
920+
h_ports = port_settings.get(private_port + '/' + protocol)
921+
if h_ports:
922+
break
921923

922924
return h_ports
923925

docker/api/exec_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ def exec_start(self, exec_id, detach=False, tty=False, stream=False,
137137
(generator or str or tuple): If ``stream=True``, a generator
138138
yielding response chunks. If ``socket=True``, a socket object for
139139
the connection. A string containing response data otherwise. If
140-
``demux=True``, stdout and stderr are separated.
140+
``demux=True``, a tuple with two elements of type byte: stdout and
141+
stderr.
141142
142143
Raises:
143144
:py:class:`docker.errors.APIError`

docker/api/image.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,15 @@ def inspect_image(self, image):
247247

248248
@utils.minimum_version('1.30')
249249
@utils.check_resource('image')
250-
def inspect_distribution(self, image):
250+
def inspect_distribution(self, image, auth_config=None):
251251
"""
252252
Get image digest and platform information by contacting the registry.
253253
254254
Args:
255255
image (str): The image name to inspect
256+
auth_config (dict): Override the credentials that are found in the
257+
config for this request. ``auth_config`` should contain the
258+
``username`` and ``password`` keys to be valid.
256259
257260
Returns:
258261
(dict): A dict containing distribution data
@@ -261,9 +264,21 @@ def inspect_distribution(self, image):
261264
:py:class:`docker.errors.APIError`
262265
If the server returns an error.
263266
"""
267+
registry, _ = auth.resolve_repository_name(image)
268+
269+
headers = {}
270+
if auth_config is None:
271+
header = auth.get_config_header(self, registry)
272+
if header:
273+
headers['X-Registry-Auth'] = header
274+
else:
275+
log.debug('Sending supplied auth config')
276+
headers['X-Registry-Auth'] = auth.encode_header(auth_config)
277+
278+
url = self._url("/distribution/{0}/json", image)
264279

265280
return self._result(
266-
self._get(self._url("/distribution/{0}/json", image)), True
281+
self._get(url, headers=headers), True
267282
)
268283

269284
def load_image(self, data, quiet=None):
@@ -336,10 +351,9 @@ def pull(self, repository, tag=None, stream=False, auth_config=None,
336351
tag (str): The tag to pull
337352
stream (bool): Stream the output as a generator. Make sure to
338353
consume the generator, otherwise pull might get cancelled.
339-
auth_config (dict): Override the credentials that
340-
:py:meth:`~docker.api.daemon.DaemonApiMixin.login` has set for
341-
this request. ``auth_config`` should contain the ``username``
342-
and ``password`` keys to be valid.
354+
auth_config (dict): Override the credentials that are found in the
355+
config for this request. ``auth_config`` should contain the
356+
``username`` and ``password`` keys to be valid.
343357
decode (bool): Decode the JSON data from the server into dicts.
344358
Only applies with ``stream=True``
345359
platform (str): Platform in the format ``os[/arch[/variant]]``
@@ -414,10 +428,9 @@ def push(self, repository, tag=None, stream=False, auth_config=None,
414428
repository (str): The repository to push to
415429
tag (str): An optional tag to push
416430
stream (bool): Stream the output as a blocking generator
417-
auth_config (dict): Override the credentials that
418-
:py:meth:`~docker.api.daemon.DaemonApiMixin.login` has set for
419-
this request. ``auth_config`` should contain the ``username``
420-
and ``password`` keys to be valid.
431+
auth_config (dict): Override the credentials that are found in the
432+
config for this request. ``auth_config`` should contain the
433+
``username`` and ``password`` keys to be valid.
421434
decode (bool): Decode the JSON data from the server into dicts.
422435
Only applies with ``stream=True``
423436

docker/api/service.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ def raise_version_error(param, min_version):
8888
if container_spec.get('Isolation') is not None:
8989
raise_version_error('ContainerSpec.isolation', '1.35')
9090

91+
if utils.version_lt(version, '1.38'):
92+
if container_spec.get('Init') is not None:
93+
raise_version_error('ContainerSpec.init', '1.38')
94+
9195
if task_template.get('Resources'):
9296
if utils.version_lt(version, '1.32'):
9397
if task_template['Resources'].get('GenericResources'):
@@ -387,7 +391,7 @@ def update_service(self, service, version, task_template=None, name=None,
387391
current specification of the service. Default: ``False``
388392
389393
Returns:
390-
``True`` if successful.
394+
A dictionary containing a ``Warnings`` key.
391395
392396
Raises:
393397
:py:class:`docker.errors.APIError`
@@ -471,5 +475,4 @@ def update_service(self, service, version, task_template=None, name=None,
471475
resp = self._post_json(
472476
url, data=data, params={'version': version}, headers=headers
473477
)
474-
self._raise_for_status(resp)
475-
return True
478+
return self._result(resp, json=True)

0 commit comments

Comments
 (0)