Merge pull request #2393 from seguins/1814-restart-stopped-containers

Fix restart with stopped containers.
This commit is contained in:
Daniel Nephin 2015-11-20 11:35:24 -05:00
commit 91fb6156c6
2 changed files with 10 additions and 1 deletions

View File

@ -185,7 +185,7 @@ class Service(object):
c.kill(**options)
def restart(self, **options):
for c in self.containers():
for c in self.containers(stopped=True):
log.info("Restarting %s" % c.name)
c.restart(**options)

View File

@ -597,6 +597,15 @@ class CLITestCase(DockerClientTestCase):
started_at,
)
def test_restart_stopped_container(self):
service = self.project.get_service('simple')
container = service.create_container()
container.start()
container.kill()
self.assertEqual(len(service.containers(stopped=True)), 1)
self.dispatch(['restart', '-t', '1'], None)
self.assertEqual(len(service.containers(stopped=False)), 1)
def test_scale(self):
project = self.project