Raise error if up used with both -d and --timeout

Fix #5434
Signed-off-by: Madeline Stager <stager.madeline@gmail.com>
This commit is contained in:
Madeline Stager 2017-12-04 20:01:00 -06:00 committed by Joffrey F
parent 34ea11fcb7
commit 58f2f10d49
2 changed files with 10 additions and 15 deletions

View File

@ -898,8 +898,8 @@ class TopLevelCommand(object):
Options:
-d Detached mode: Run containers in the background,
print new container names.
Incompatible with --abort-on-container-exit.
print new container names. Incompatible with
--abort-on-container-exit and --timeout.
--no-color Produce monochrome output.
--no-deps Don't start linked services.
--force-recreate Recreate containers even if their configuration
@ -913,7 +913,8 @@ class TopLevelCommand(object):
--abort-on-container-exit Stops all containers if any container was stopped.
Incompatible with -d.
-t, --timeout TIMEOUT Use this timeout in seconds for container shutdown
when attached or when containers are already
when attached or when containers are already.
Incompatible with -d.
running. (default: 10)
--remove-orphans Remove containers for services not
defined in the Compose file
@ -934,6 +935,9 @@ class TopLevelCommand(object):
if detached and (cascade_stop or exit_value_from):
raise UserError("--abort-on-container-exit and -d cannot be combined.")
if detached and timeout:
raise UserError("-d and --timeout cannot be combined.")
if no_start:
for excluded in ['-d', '--abort-on-container-exit', '--exit-code-from']:
if options.get(excluded):

View File

@ -1325,18 +1325,9 @@ class CLITestCase(DockerClientTestCase):
['up', '-d', '--force-recreate', '--no-recreate'],
returncode=1)
def test_up_with_timeout(self):
self.dispatch(['up', '-d', '-t', '1'])
service = self.project.get_service('simple')
another = self.project.get_service('another')
self.assertEqual(len(service.containers()), 1)
self.assertEqual(len(another.containers()), 1)
# Ensure containers don't have stdin and stdout connected in -d mode
config = service.containers()[0].inspect()['Config']
self.assertFalse(config['AttachStderr'])
self.assertFalse(config['AttachStdout'])
self.assertFalse(config['AttachStdin'])
def test_up_with_timeout_detached(self):
result = self.dispatch(['up', '-d', '-t', '1'], returncode=1)
assert "-d and --timeout cannot be combined." in result.stderr
def test_up_handles_sigint(self):
proc = start_process(self.base_dir, ['up', '-t', '2'])