mirror of https://github.com/docker/compose.git
Add --no-start flag to up command. Deprecate create command.
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
5b4573e7e5
commit
9587556e8f
|
@ -319,6 +319,7 @@ class TopLevelCommand(object):
|
||||||
def create(self, options):
|
def create(self, options):
|
||||||
"""
|
"""
|
||||||
Creates containers for a service.
|
Creates containers for a service.
|
||||||
|
This command is deprecated. Use the `up` command with `--no-start` instead.
|
||||||
|
|
||||||
Usage: create [options] [SERVICE...]
|
Usage: create [options] [SERVICE...]
|
||||||
|
|
||||||
|
@ -332,6 +333,11 @@ class TopLevelCommand(object):
|
||||||
"""
|
"""
|
||||||
service_names = options['SERVICE']
|
service_names = options['SERVICE']
|
||||||
|
|
||||||
|
log.warn(
|
||||||
|
'The create command is deprecated. '
|
||||||
|
'Use the up command with the --no-start flag instead.'
|
||||||
|
)
|
||||||
|
|
||||||
self.project.create(
|
self.project.create(
|
||||||
service_names=service_names,
|
service_names=service_names,
|
||||||
strategy=convergence_strategy_from_opts(options),
|
strategy=convergence_strategy_from_opts(options),
|
||||||
|
@ -902,6 +908,7 @@ class TopLevelCommand(object):
|
||||||
--no-recreate If containers already exist, don't recreate them.
|
--no-recreate If containers already exist, don't recreate them.
|
||||||
Incompatible with --force-recreate.
|
Incompatible with --force-recreate.
|
||||||
--no-build Don't build an image, even if it's missing.
|
--no-build Don't build an image, even if it's missing.
|
||||||
|
--no-start Don't start the services after creating them.
|
||||||
--build Build images before starting containers.
|
--build Build images before starting containers.
|
||||||
--abort-on-container-exit Stops all containers if any container was stopped.
|
--abort-on-container-exit Stops all containers if any container was stopped.
|
||||||
Incompatible with -d.
|
Incompatible with -d.
|
||||||
|
@ -922,10 +929,16 @@ class TopLevelCommand(object):
|
||||||
timeout = timeout_from_opts(options)
|
timeout = timeout_from_opts(options)
|
||||||
remove_orphans = options['--remove-orphans']
|
remove_orphans = options['--remove-orphans']
|
||||||
detached = options.get('-d')
|
detached = options.get('-d')
|
||||||
|
no_start = options.get('--no-start')
|
||||||
|
|
||||||
if detached and cascade_stop:
|
if detached and (cascade_stop or exit_value_from):
|
||||||
raise UserError("--abort-on-container-exit and -d cannot be combined.")
|
raise UserError("--abort-on-container-exit and -d cannot be combined.")
|
||||||
|
|
||||||
|
if no_start:
|
||||||
|
for excluded in ['-d', '--abort-on-container-exit', '--exit-code-from']:
|
||||||
|
if options.get(excluded):
|
||||||
|
raise UserError('--no-start and {} cannot be combined.'.format(excluded))
|
||||||
|
|
||||||
with up_shutdown_context(self.project, service_names, timeout, detached):
|
with up_shutdown_context(self.project, service_names, timeout, detached):
|
||||||
to_attach = self.project.up(
|
to_attach = self.project.up(
|
||||||
service_names=service_names,
|
service_names=service_names,
|
||||||
|
@ -936,9 +949,10 @@ class TopLevelCommand(object):
|
||||||
detached=detached,
|
detached=detached,
|
||||||
remove_orphans=remove_orphans,
|
remove_orphans=remove_orphans,
|
||||||
scale_override=parse_scale_args(options['--scale']),
|
scale_override=parse_scale_args(options['--scale']),
|
||||||
|
start=not no_start
|
||||||
)
|
)
|
||||||
|
|
||||||
if detached:
|
if detached or no_start:
|
||||||
return
|
return
|
||||||
|
|
||||||
attached_containers = filter_containers_to_service_names(to_attach, service_names)
|
attached_containers = filter_containers_to_service_names(to_attach, service_names)
|
||||||
|
|
|
@ -412,7 +412,8 @@ class Project(object):
|
||||||
detached=False,
|
detached=False,
|
||||||
remove_orphans=False,
|
remove_orphans=False,
|
||||||
scale_override=None,
|
scale_override=None,
|
||||||
rescale=True):
|
rescale=True,
|
||||||
|
start=True):
|
||||||
|
|
||||||
warn_for_swarm_mode(self.client)
|
warn_for_swarm_mode(self.client)
|
||||||
|
|
||||||
|
@ -436,7 +437,8 @@ class Project(object):
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
detached=detached,
|
detached=detached,
|
||||||
scale_override=scale_override.get(service.name),
|
scale_override=scale_override.get(service.name),
|
||||||
rescale=rescale
|
rescale=rescale,
|
||||||
|
start=start
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_deps(service):
|
def get_deps(service):
|
||||||
|
|
|
@ -776,6 +776,31 @@ class CLITestCase(DockerClientTestCase):
|
||||||
for service in services:
|
for service in services:
|
||||||
assert self.lookup(container, service.name)
|
assert self.lookup(container, service.name)
|
||||||
|
|
||||||
|
@v2_only()
|
||||||
|
def test_up_no_start(self):
|
||||||
|
self.base_dir = 'tests/fixtures/v2-full'
|
||||||
|
self.dispatch(['up', '--no-start'], None)
|
||||||
|
|
||||||
|
services = self.project.get_services()
|
||||||
|
|
||||||
|
default_network = self.project.networks.networks['default'].full_name
|
||||||
|
front_network = self.project.networks.networks['front'].full_name
|
||||||
|
networks = self.client.networks(names=[default_network, front_network])
|
||||||
|
assert len(networks) == 2
|
||||||
|
|
||||||
|
for service in services:
|
||||||
|
containers = service.containers(stopped=True)
|
||||||
|
assert len(containers) == 1
|
||||||
|
|
||||||
|
container = containers[0]
|
||||||
|
assert not container.is_running
|
||||||
|
assert container.get('State.Status') == 'created'
|
||||||
|
|
||||||
|
volumes = self.project.volumes.volumes
|
||||||
|
assert 'data' in volumes
|
||||||
|
volume = volumes['data']
|
||||||
|
assert volume.exists()
|
||||||
|
|
||||||
@v2_only()
|
@v2_only()
|
||||||
def test_up_no_ansi(self):
|
def test_up_no_ansi(self):
|
||||||
self.base_dir = 'tests/fixtures/v2-simple'
|
self.base_dir = 'tests/fixtures/v2-simple'
|
||||||
|
|
Loading…
Reference in New Issue