Add an acceptance test and docs for the down subcommand
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
c8ed156806
commit
c64af0a459
13 changed files with 102 additions and 13 deletions
|
|
@ -247,7 +247,7 @@ class TopLevelCommand(DocoptCommand):
|
|||
def down(self, project, options):
|
||||
"""
|
||||
Stop containers and remove containers, networks, volumes, and images
|
||||
created by `up`.
|
||||
created by `up`. Only containers and networks are removed by default.
|
||||
|
||||
Usage: down [options]
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ def parallel_execute(objects, func, index_func, msg):
|
|||
object we give it.
|
||||
"""
|
||||
objects = list(objects)
|
||||
stream = get_output_stream(sys.stdout)
|
||||
stream = get_output_stream(sys.stderr)
|
||||
writer = ParallelStreamWriter(stream, msg)
|
||||
|
||||
for obj in objects:
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ class Project(object):
|
|||
|
||||
def down(self, remove_image_type, include_volumes):
|
||||
self.stop()
|
||||
self.remove_stopped()
|
||||
self.remove_stopped(v=include_volumes)
|
||||
self.remove_network()
|
||||
|
||||
if include_volumes:
|
||||
|
|
@ -441,6 +441,7 @@ class Project(object):
|
|||
return
|
||||
network = self.get_network()
|
||||
if network:
|
||||
log.info("Removing network %s", self.default_network_name)
|
||||
self.client.remove_network(network['Id'])
|
||||
|
||||
def uses_default_network(self):
|
||||
|
|
|
|||
|
|
@ -686,6 +686,7 @@ class Service(object):
|
|||
if image_type == ImageType.local and self.options.get('image'):
|
||||
return False
|
||||
|
||||
log.info("Removing image %s", self.image_name)
|
||||
try:
|
||||
self.client.remove_image(self.image_name)
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from docker.errors import NotFound
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Volume(object):
|
||||
def __init__(self, client, project, name, driver=None, driver_opts=None,
|
||||
external_name=None):
|
||||
|
|
@ -20,6 +25,10 @@ class Volume(object):
|
|||
)
|
||||
|
||||
def remove(self):
|
||||
if self.external:
|
||||
log.info("Volume %s is external, skipping", self.full_name)
|
||||
return
|
||||
log.info("Removing volume %s", self.full_name)
|
||||
return self.client.remove_volume(self.full_name)
|
||||
|
||||
def inspect(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue