From d41e06092dd228c2409c61b0d6ed60d2b83eb5c5 Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Thu, 22 Feb 2018 14:59:19 -0800 Subject: [PATCH 1/8] 3.2.0-dev Signed-off-by: Joffrey F --- docker/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/version.py b/docker/version.py index c79cf93d..3429f284 100644 --- a/docker/version.py +++ b/docker/version.py @@ -1,2 +1,2 @@ -version = "3.1.0" +version = "3.2.0-dev" version_info = tuple([int(d) for d in version.split("-")[0].split(".")]) From ab1f90a379bfb781c821ba8210e76bfa5551ea60 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Fri, 23 Feb 2018 02:22:19 +0000 Subject: [PATCH 2/8] Cleanup containers during the tests This fix tries to clean up the containers during the tests so that no pre-existing volumes left in docker integration tests. This fix adds `-v` when removing containers, and makes sure containers launched in non-daemon mode are removed. This fix is realted to moby PR 36292 Signed-off-by: Yong Tang --- tests/integration/base.py | 2 +- tests/integration/models_containers_test.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/integration/base.py b/tests/integration/base.py index c22126d5..56c23ed4 100644 --- a/tests/integration/base.py +++ b/tests/integration/base.py @@ -36,7 +36,7 @@ class BaseIntegrationTest(unittest.TestCase): pass for container in self.tmp_containers: try: - client.api.remove_container(container, force=True) + client.api.remove_container(container, force=True, v=True) except docker.errors.APIError: pass for network in self.tmp_networks: diff --git a/tests/integration/models_containers_test.py b/tests/integration/models_containers_test.py index f9f59c43..fac4de2b 100644 --- a/tests/integration/models_containers_test.py +++ b/tests/integration/models_containers_test.py @@ -47,10 +47,13 @@ class ContainerCollectionTest(BaseIntegrationTest): self.tmp_containers.append(container.id) container.wait() + name = "container_volume_test" out = client.containers.run( "alpine", "cat /insidecontainer/test", - volumes=["%s:/insidecontainer" % path] + volumes=["%s:/insidecontainer" % path], + name=name ) + self.tmp_containers.append(name) assert out == b'hello\n' def test_run_with_named_volume(self): @@ -66,10 +69,13 @@ class ContainerCollectionTest(BaseIntegrationTest): self.tmp_containers.append(container.id) container.wait() + name = "container_volume_test" out = client.containers.run( "alpine", "cat /insidecontainer/test", - volumes=["somevolume:/insidecontainer"] + volumes=["somevolume:/insidecontainer"], + name=name ) + self.tmp_containers.append(name) assert out == b'hello\n' def test_run_with_network(self): From 429591910359dd7487dc111298eaf1f36121631d Mon Sep 17 00:00:00 2001 From: mefyl Date: Mon, 26 Feb 2018 12:17:34 +0100 Subject: [PATCH 3/8] Add test for "/.." patterns in .dockerignore. Signed-off-by: mefyl --- tests/unit/utils_test.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py index 8a4b1937..c2dd502b 100644 --- a/tests/unit/utils_test.py +++ b/tests/unit/utils_test.py @@ -902,6 +902,22 @@ class ExcludePathsTest(unittest.TestCase): ['*.md', '!README*.md', 'README-secret.md'] ) == set(['README.md', 'README-bis.md']) + def test_parent_directory(self): + base = make_tree( + [], + ['a.py', + 'b.py', + 'c.py']) + # Dockerignore reference stipulates that absolute paths are + # equivalent to relative paths, hence /../foo should be + # equivalent to ../foo. It also stipulates that paths are run + # through Go's filepath.Clean, which explicitely "replace + # "/.." by "/" at the beginning of a path". + assert exclude_paths( + base, + ['../a.py', '/../b.py'] + ) == set(['c.py']) + class TarTest(unittest.TestCase): def test_tar_with_excludes(self): From 15c26e7057b6b7a95297c3324ddf5cbe7dad4353 Mon Sep 17 00:00:00 2001 From: Matthieu Nottale Date: Mon, 26 Feb 2018 14:37:27 +0100 Subject: [PATCH 4/8] Workaround requests resolving our unix socket URL on macosx. Signed-off-by: Matthieu Nottale --- docker/api/client.py | 4 +++- tests/unit/fake_api.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docker/api/client.py b/docker/api/client.py index bddab61f..13c292a0 100644 --- a/docker/api/client.py +++ b/docker/api/client.py @@ -119,7 +119,9 @@ class APIClient( ) self.mount('http+docker://', self._custom_adapter) self._unmount('http://', 'https://') - self.base_url = 'http+docker://localunixsocket' + # host part of URL should be unused, but is resolved by requests + # module in proxy_bypass_macosx_sysconf() + self.base_url = 'http+docker://localhost' elif base_url.startswith('npipe://'): if not IS_WINDOWS_PLATFORM: raise DockerException( diff --git a/tests/unit/fake_api.py b/tests/unit/fake_api.py index 63d73317..e609b64e 100644 --- a/tests/unit/fake_api.py +++ b/tests/unit/fake_api.py @@ -512,7 +512,7 @@ def post_fake_network_disconnect(): # Maps real api url to fake response callback -prefix = 'http+docker://localunixsocket' +prefix = 'http+docker://localhost' if constants.IS_WINDOWS_PLATFORM: prefix = 'http+docker://localnpipe' From 7a28ff351018eae9484451798c22db3c190547d0 Mon Sep 17 00:00:00 2001 From: Wanzhi Du Date: Mon, 5 Mar 2018 18:01:22 +0800 Subject: [PATCH 5/8] Ignore comment line from the .dockerignore file This fixed the bug that test comment line in .dockerignore file as ignore rule bug. Add test for "# comment" patterns in .dockerignore. Signed-off-by: Wanzhi Du --- docker/api/build.py | 2 +- tests/integration/api_build_test.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docker/api/build.py b/docker/api/build.py index 56f1fcfc..6dab14dc 100644 --- a/docker/api/build.py +++ b/docker/api/build.py @@ -143,7 +143,7 @@ class BuildApiMixin(object): if os.path.exists(dockerignore): with open(dockerignore, 'r') as f: exclude = list(filter( - bool, [l.strip() for l in f.read().splitlines()] + lambda x: x != '' and x[0] != '#', [l.strip() for l in f.read().splitlines()] )) context = utils.tar( path, exclude=exclude, dockerfile=dockerfile, gzip=gzip diff --git a/tests/integration/api_build_test.py b/tests/integration/api_build_test.py index 4c2b9920..a8c02796 100644 --- a/tests/integration/api_build_test.py +++ b/tests/integration/api_build_test.py @@ -61,7 +61,8 @@ class BuildTest(BaseAPIIntegrationTest): 'Dockerfile', '.dockerignore', '!ignored/subdir/excepted-file', - '', # empty line + '', # empty line, + '#', # comment line ])) with open(os.path.join(base_dir, 'not-ignored'), 'w') as f: From 74586cdd4c661ecc4a3e3bd64fafedde7f121d5e Mon Sep 17 00:00:00 2001 From: Wanzhi Du Date: Mon, 5 Mar 2018 19:26:56 +0800 Subject: [PATCH 6/8] Fix flake8 case Signed-off-by: Wanzhi Du --- docker/api/build.py | 3 ++- tests/integration/api_build_test.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docker/api/build.py b/docker/api/build.py index 6dab14dc..e136a6ee 100644 --- a/docker/api/build.py +++ b/docker/api/build.py @@ -143,7 +143,8 @@ class BuildApiMixin(object): if os.path.exists(dockerignore): with open(dockerignore, 'r') as f: exclude = list(filter( - lambda x: x != '' and x[0] != '#', [l.strip() for l in f.read().splitlines()] + lambda x: x != '' and x[0] != '#', + [l.strip() for l in f.read().splitlines()] )) context = utils.tar( path, exclude=exclude, dockerfile=dockerfile, gzip=gzip diff --git a/tests/integration/api_build_test.py b/tests/integration/api_build_test.py index a8c02796..ad5fbaa8 100644 --- a/tests/integration/api_build_test.py +++ b/tests/integration/api_build_test.py @@ -62,7 +62,7 @@ class BuildTest(BaseAPIIntegrationTest): '.dockerignore', '!ignored/subdir/excepted-file', '', # empty line, - '#', # comment line + '#', # comment line ])) with open(os.path.join(base_dir, 'not-ignored'), 'w') as f: From 13609359acfc33c42bda35ad240c4a8d96df13d4 Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Mon, 5 Mar 2018 11:49:43 -0800 Subject: [PATCH 7/8] Improve dockerignore comment test Signed-off-by: Joffrey F --- tests/integration/api_build_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/integration/api_build_test.py b/tests/integration/api_build_test.py index ad5fbaa8..ce587d54 100644 --- a/tests/integration/api_build_test.py +++ b/tests/integration/api_build_test.py @@ -62,12 +62,15 @@ class BuildTest(BaseAPIIntegrationTest): '.dockerignore', '!ignored/subdir/excepted-file', '', # empty line, - '#', # comment line + '#*', # comment line ])) with open(os.path.join(base_dir, 'not-ignored'), 'w') as f: f.write("this file should not be ignored") + with open(os.path.join(base_dir, '#file.txt'), 'w') as f: + f.write('this file should not be ignored') + subdir = os.path.join(base_dir, 'ignored', 'subdir') os.makedirs(subdir) with open(os.path.join(subdir, 'file'), 'w') as f: @@ -93,6 +96,7 @@ class BuildTest(BaseAPIIntegrationTest): logs = logs.decode('utf-8') assert sorted(list(filter(None, logs.split('\n')))) == sorted([ + '/test/#file.txt', '/test/ignored/subdir/excepted-file', '/test/not-ignored' ]) From 52c3d528f64dbc9bd155ae9bc74b454f842761c5 Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Mon, 5 Mar 2018 15:15:37 -0800 Subject: [PATCH 8/8] Bump 3.1.1 Signed-off-by: Joffrey F --- docker/version.py | 2 +- docs/change-log.md | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docker/version.py b/docker/version.py index 3429f284..fedd9ed7 100644 --- a/docker/version.py +++ b/docker/version.py @@ -1,2 +1,2 @@ -version = "3.2.0-dev" +version = "3.1.1" version_info = tuple([int(d) for d in version.split("-")[0].split(".")]) diff --git a/docs/change-log.md b/docs/change-log.md index ceab083e..94c325d6 100644 --- a/docs/change-log.md +++ b/docs/change-log.md @@ -1,6 +1,18 @@ Change log ========== +3.1.1 +----- + +[List of PRs / issues for this release](https://github.com/docker/docker-py/milestone/46?closed=1) + +### Bugfixes + +* Fixed a bug that caused costly DNS lookups on Mac OSX when connecting to the + engine through UNIX socket +* Fixed a bug that caused `.dockerignore` comments to be read as exclusion + patterns + 3.1.0 -----