From 59cc9c9b68c4ec3a957b67c9f4f776e7543eefb1 Mon Sep 17 00:00:00 2001 From: Mark Steve Samson Date: Wed, 5 Mar 2014 09:01:31 +0800 Subject: [PATCH] Add option to remove container in `docker run` (Closes #137) --- fig/cli/main.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fig/cli/main.py b/fig/cli/main.py index 4d65ce9e4..4188d7708 100644 --- a/fig/cli/main.py +++ b/fig/cli/main.py @@ -209,6 +209,7 @@ class TopLevelCommand(Command): container name -T Disable pseudo-tty allocation. By default `fig run` allocates a TTY. + --rm Remove container after run. Ignored in detached mode. """ 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: service.start_container(container, ports=None) c.run() + if options['--rm']: + container.wait() + log.info("Removing %s..." % container.name) + self.client.remove_container(container.id) def scale(self, options): """