mirror of https://github.com/docker/compose.git
Attach interactively on Windows by shelling out
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
8b383ad795
commit
8314a48a2e
|
@ -7,6 +7,7 @@ import functools
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from inspect import getdoc
|
from inspect import getdoc
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
@ -406,11 +407,6 @@ class TopLevelCommand(object):
|
||||||
service = self.project.get_service(options['SERVICE'])
|
service = self.project.get_service(options['SERVICE'])
|
||||||
detach = options['-d']
|
detach = options['-d']
|
||||||
|
|
||||||
if IS_WINDOWS_PLATFORM and not detach:
|
|
||||||
raise UserError(
|
|
||||||
"Interactive mode is not yet supported on Windows.\n"
|
|
||||||
"Please pass the -d flag when using `docker-compose exec`."
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
container = service.get_container(number=index)
|
container = service.get_container(number=index)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
|
@ -418,6 +414,28 @@ class TopLevelCommand(object):
|
||||||
command = [options['COMMAND']] + options['ARGS']
|
command = [options['COMMAND']] + options['ARGS']
|
||||||
tty = not options["-T"]
|
tty = not options["-T"]
|
||||||
|
|
||||||
|
if IS_WINDOWS_PLATFORM and not detach:
|
||||||
|
args = ["docker", "exec"]
|
||||||
|
|
||||||
|
if options["-d"]:
|
||||||
|
args += ["--detach"]
|
||||||
|
else:
|
||||||
|
args += ["--interactive"]
|
||||||
|
|
||||||
|
if not options["-T"]:
|
||||||
|
args += ["--tty"]
|
||||||
|
|
||||||
|
if options["--privileged"]:
|
||||||
|
args += ["--privileged"]
|
||||||
|
|
||||||
|
if options["--user"]:
|
||||||
|
args += ["--user", options["--user"]]
|
||||||
|
|
||||||
|
args += [container.id]
|
||||||
|
args += command
|
||||||
|
|
||||||
|
sys.exit(subprocess.call(args))
|
||||||
|
|
||||||
create_exec_options = {
|
create_exec_options = {
|
||||||
"privileged": options["--privileged"],
|
"privileged": options["--privileged"],
|
||||||
"user": options["--user"],
|
"user": options["--user"],
|
||||||
|
@ -675,12 +693,6 @@ class TopLevelCommand(object):
|
||||||
service = self.project.get_service(options['SERVICE'])
|
service = self.project.get_service(options['SERVICE'])
|
||||||
detach = options['-d']
|
detach = options['-d']
|
||||||
|
|
||||||
if IS_WINDOWS_PLATFORM 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['--publish'] and options['--service-ports']:
|
if options['--publish'] and options['--service-ports']:
|
||||||
raise UserError(
|
raise UserError(
|
||||||
'Service port mapping and manual port mapping '
|
'Service port mapping and manual port mapping '
|
||||||
|
@ -969,6 +981,10 @@ def run_one_off_container(container_options, project, service, options):
|
||||||
signals.set_signal_handler_to_shutdown()
|
signals.set_signal_handler_to_shutdown()
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
|
if IS_WINDOWS_PLATFORM:
|
||||||
|
args = ["docker", "start", "--attach", "--interactive", container.id]
|
||||||
|
exit_code = subprocess.call(args)
|
||||||
|
else:
|
||||||
operation = RunOperation(
|
operation = RunOperation(
|
||||||
project.client,
|
project.client,
|
||||||
container.id,
|
container.id,
|
||||||
|
|
Loading…
Reference in New Issue