mirror of https://github.com/docker/compose.git
Provide option to remove volumes in `fig rm`
This commit is contained in:
parent
c66e18c913
commit
41bacae171
|
@ -170,6 +170,9 @@ class TopLevelCommand(Command):
|
||||||
Remove stopped service containers.
|
Remove stopped service containers.
|
||||||
|
|
||||||
Usage: rm [SERVICE...]
|
Usage: rm [SERVICE...]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-v Remove volumes associated with containers
|
||||||
"""
|
"""
|
||||||
all_containers = self.project.containers(service_names=options['SERVICE'], stopped=True)
|
all_containers = self.project.containers(service_names=options['SERVICE'], stopped=True)
|
||||||
stopped_containers = [c for c in all_containers if not c.is_running]
|
stopped_containers = [c for c in all_containers if not c.is_running]
|
||||||
|
@ -177,7 +180,8 @@ class TopLevelCommand(Command):
|
||||||
if len(stopped_containers) > 0:
|
if len(stopped_containers) > 0:
|
||||||
print("Going to remove", list_containers(stopped_containers))
|
print("Going to remove", list_containers(stopped_containers))
|
||||||
if yesno("Are you sure? [yN] ", default=False):
|
if yesno("Are you sure? [yN] ", default=False):
|
||||||
self.project.remove_stopped(service_names=options['SERVICE'])
|
self.project.remove_stopped(service_names=options['SERVICE'],
|
||||||
|
remove_volumes=options['-v'])
|
||||||
else:
|
else:
|
||||||
print("No stopped containers")
|
print("No stopped containers")
|
||||||
|
|
||||||
|
|
|
@ -111,8 +111,9 @@ class Container(object):
|
||||||
def kill(self):
|
def kill(self):
|
||||||
return self.client.kill(self.id)
|
return self.client.kill(self.id)
|
||||||
|
|
||||||
def remove(self):
|
def remove(self, **options):
|
||||||
return self.client.remove_container(self.id)
|
v = options.get('remove_volumes', False)
|
||||||
|
return self.client.remove_container(self.id, v=v)
|
||||||
|
|
||||||
def inspect_if_not_inspected(self):
|
def inspect_if_not_inspected(self):
|
||||||
if not self.has_been_inspected:
|
if not self.has_been_inspected:
|
||||||
|
|
Loading…
Reference in New Issue