mirror of
https://github.com/docker/compose.git
synced 2025-07-25 14:44:29 +02:00
Stub 'run' on Windows
Adapted from @dopry's work in https://github.com/docker/compose/pull/1900 Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
bbc8b74c17
commit
3e4182a480
@ -8,7 +8,6 @@ import sys
|
|||||||
from inspect import getdoc
|
from inspect import getdoc
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
|
||||||
import dockerpty
|
|
||||||
from docker.errors import APIError
|
from docker.errors import APIError
|
||||||
from requests.exceptions import ReadTimeout
|
from requests.exceptions import ReadTimeout
|
||||||
|
|
||||||
@ -31,6 +30,11 @@ from .log_printer import LogPrinter
|
|||||||
from .utils import get_version_info
|
from .utils import get_version_info
|
||||||
from .utils import yesno
|
from .utils import yesno
|
||||||
|
|
||||||
|
WINDOWS = (sys.platform == 'win32')
|
||||||
|
|
||||||
|
if not WINDOWS:
|
||||||
|
import dockerpty
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
console_handler = logging.StreamHandler(sys.stderr)
|
console_handler = logging.StreamHandler(sys.stderr)
|
||||||
|
|
||||||
@ -335,6 +339,14 @@ class TopLevelCommand(Command):
|
|||||||
"""
|
"""
|
||||||
service = project.get_service(options['SERVICE'])
|
service = project.get_service(options['SERVICE'])
|
||||||
|
|
||||||
|
detach = options['-d']
|
||||||
|
|
||||||
|
if WINDOWS and not detach:
|
||||||
|
raise UserError(
|
||||||
|
"Interactive mode is not yet supported on Windows.\n"
|
||||||
|
"Please pass the -d flag when using `docker-compose run`."
|
||||||
|
)
|
||||||
|
|
||||||
if options['--allow-insecure-ssl']:
|
if options['--allow-insecure-ssl']:
|
||||||
log.warn(INSECURE_SSL_WARNING)
|
log.warn(INSECURE_SSL_WARNING)
|
||||||
|
|
||||||
@ -349,7 +361,7 @@ class TopLevelCommand(Command):
|
|||||||
)
|
)
|
||||||
|
|
||||||
tty = True
|
tty = True
|
||||||
if options['-d'] or options['-T'] or not sys.stdin.isatty():
|
if detach or options['-T'] or not sys.stdin.isatty():
|
||||||
tty = False
|
tty = False
|
||||||
|
|
||||||
if options['COMMAND']:
|
if options['COMMAND']:
|
||||||
@ -360,8 +372,8 @@ class TopLevelCommand(Command):
|
|||||||
container_options = {
|
container_options = {
|
||||||
'command': command,
|
'command': command,
|
||||||
'tty': tty,
|
'tty': tty,
|
||||||
'stdin_open': not options['-d'],
|
'stdin_open': not detach,
|
||||||
'detach': options['-d'],
|
'detach': detach,
|
||||||
}
|
}
|
||||||
|
|
||||||
if options['-e']:
|
if options['-e']:
|
||||||
@ -407,7 +419,7 @@ class TopLevelCommand(Command):
|
|||||||
|
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
if options['-d']:
|
if detach:
|
||||||
service.start_container(container)
|
service.start_container(container)
|
||||||
print(container.name)
|
print(container.name)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user