浏览代码

Remove one-off containers in 'docker-compose down'

Signed-off-by: Aanand Prasad <[email protected]>
Aanand Prasad 9 年之前
父节点
当前提交
a2317dfac2
共有 2 个文件被更改,包括 6 次插入1 次删除
  1. 1 1
      compose/project.py
  2. 5 0
      tests/acceptance/cli_test.py

+ 1 - 1
compose/project.py

@@ -276,7 +276,7 @@ class Project(object):
     def down(self, remove_image_type, include_volumes, remove_orphans=False):
         self.stop()
         self.find_orphan_containers(remove_orphans)
-        self.remove_stopped(v=include_volumes)
+        self.remove_stopped(v=include_volumes, one_off=OneOffFilter.include)
 
         self.networks.remove()
 

+ 5 - 0
tests/acceptance/cli_test.py

@@ -366,14 +366,19 @@ class CLITestCase(DockerClientTestCase):
     @v2_only()
     def test_down(self):
         self.base_dir = 'tests/fixtures/v2-full'
+
         self.dispatch(['up', '-d'])
         wait_on_condition(ContainerCountCondition(self.project, 2))
 
+        self.dispatch(['run', 'web', 'true'])
+        assert len(self.project.containers(one_off=OneOffFilter.only, stopped=True)) == 1
+
         result = self.dispatch(['down', '--rmi=local', '--volumes'])
         assert 'Stopping v2full_web_1' in result.stderr
         assert 'Stopping v2full_other_1' in result.stderr
         assert 'Removing v2full_web_1' in result.stderr
         assert 'Removing v2full_other_1' in result.stderr
+        assert 'Removing v2full_web_run_1' in result.stderr
         assert 'Removing volume v2full_data' in result.stderr
         assert 'Removing image v2full_web' in result.stderr
         assert 'Removing image busybox' not in result.stderr