1
0
Эх сурвалжийг харах

Merge pull request #6494 from collin5/b6464

Only pull images that can't build `docker-compose pull`
Ian Campbell 6 жил өмнө
parent
commit
6ccbb56fec

+ 5 - 2
compose/project.py

@@ -601,6 +601,9 @@ class Project(object):
     def pull(self, service_names=None, ignore_pull_failures=False, parallel_pull=False, silent=False,
              include_deps=False):
         services = self.get_services(service_names, include_deps)
+        images_to_build = {service.image_name for service in services if service.can_be_built()}
+        services_to_pull = [service for service in services if service.image_name not in images_to_build]
+
         msg = not silent and 'Pulling' or None
 
         if parallel_pull:
@@ -626,7 +629,7 @@ class Project(object):
                     )
 
             _, errors = parallel.parallel_execute(
-                services,
+                services_to_pull,
                 pull_service,
                 operator.attrgetter('name'),
                 msg,
@@ -639,7 +642,7 @@ class Project(object):
                 raise ProjectError(combined_errors)
 
         else:
-            for service in services:
+            for service in services_to_pull:
                 service.pull(ignore_pull_failures, silent=silent)
 
     def push(self, service_names=None, ignore_push_failures=False):

+ 7 - 0
tests/acceptance/cli_test.py

@@ -655,6 +655,13 @@ class CLITestCase(DockerClientTestCase):
                 'image library/nonexisting-image:latest not found' in result.stderr or
                 'pull access denied for nonexisting-image' in result.stderr)
 
+    def test_pull_with_build(self):
+        result = self.dispatch(['-f', 'pull-with-build.yml', 'pull'])
+
+        assert 'Pulling simple' not in result.stderr
+        assert 'Pulling from_simple' not in result.stderr
+        assert 'Pulling another ...' in result.stderr
+
     def test_pull_with_quiet(self):
         assert self.dispatch(['pull', '--quiet']).stderr == ''
         assert self.dispatch(['pull', '--quiet']).stdout == ''

+ 11 - 0
tests/fixtures/simple-composefile/pull-with-build.yml

@@ -0,0 +1,11 @@
+version: "3"
+services:
+  build_simple:
+    image: simple
+    build: .
+    command: top
+  from_simple:
+    image: simple
+  another:
+    image: busybox:latest
+    command: top