Add option to remove container in `docker run` (Closes #137)

This commit is contained in:
Mark Steve Samson 2014-03-05 09:01:31 +08:00
parent 6813cb86a2
commit 59cc9c9b68
1 changed files with 5 additions and 0 deletions

View File

@ -209,6 +209,7 @@ class TopLevelCommand(Command):
container name container name
-T Disable pseudo-tty allocation. By default `fig run` -T Disable pseudo-tty allocation. By default `fig run`
allocates a TTY. allocates a TTY.
--rm Remove container after run. Ignored in detached mode.
""" """
service = self.project.get_service(options['SERVICE']) service = self.project.get_service(options['SERVICE'])
@ -229,6 +230,10 @@ class TopLevelCommand(Command):
with self._attach_to_container(container.id, raw=tty) as c: with self._attach_to_container(container.id, raw=tty) as c:
service.start_container(container, ports=None) service.start_container(container, ports=None)
c.run() c.run()
if options['--rm']:
container.wait()
log.info("Removing %s..." % container.name)
self.client.remove_container(container.id)
def scale(self, options): def scale(self, options):
""" """