From b10791267933a9c8b2fc9a94ebae1a2930cbee8f Mon Sep 17 00:00:00 2001 From: Darrel O'Pry Date: Tue, 25 Aug 2015 13:44:44 -0400 Subject: [PATCH 1/2] Run on windows by bypassing dockerpty. Signed-off-by: Darrel O'Pry --- compose/cli/main.py | 11 ++++++++++- setup.py | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/compose/cli/main.py b/compose/cli/main.py index 890a3c37177..4120ff6c48b 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -8,7 +8,6 @@ from inspect import getdoc from operator import attrgetter -import dockerpty from docker.errors import APIError from .. import __version__ @@ -28,6 +27,9 @@ from .utils import get_version_info from .utils import yesno +if sys.platform != 'win32': + import dockerpty + log = logging.getLogger(__name__) console_handler = logging.StreamHandler(sys.stderr) @@ -393,6 +395,13 @@ def run(self, project, options): if options['-d']: service.start_container(container) print(container.name) + elif sys.platform == 'win32': + raise UserError( + 'Only detached mode is supported on Windows. You must run ' + 'compose with the -d option. If you wish to help getting ' + 'terminal mode support working, PRs are welcome! We need to ' + 'replace dockerpty or remove its depedency on fcntl.' + ) else: dockerpty.start(project.client, container.id, interactive=not options['-T']) exit_code = container.wait() diff --git a/setup.py b/setup.py index 33335047bca..b567da45507 100644 --- a/setup.py +++ b/setup.py @@ -34,11 +34,13 @@ def find_version(*file_paths): 'texttable >= 0.8.1, < 0.9', 'websocket-client >= 0.32.0, < 1.0', 'docker-py >= 1.3.1, < 1.4', - 'dockerpty >= 0.3.4, < 0.4', 'six >= 1.3.0, < 2', 'jsonschema >= 2.5.1, < 3', ] +if (sys.platform != 'win32'): + install_requires.append('dockerpty >= 0.3.4, < 0.4') + tests_require = [ 'nose', From 841c16c82d5c1e52571a25e878b0a963fc13f215 Mon Sep 17 00:00:00 2001 From: Darrel O'Pry Date: Tue, 25 Aug 2015 13:45:43 -0400 Subject: [PATCH 2/2] Better error message for AF_UNIX socket exception on windows. Signed-off-by: Darrel O'Pry --- compose/cli/main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compose/cli/main.py b/compose/cli/main.py index 4120ff6c48b..21b559aa3b9 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -67,6 +67,14 @@ def main(): except NeedsBuildError as e: log.error("Service '%s' needs to be built, but --no-build was passed." % e.service.name) sys.exit(1) + except AttributeError as e: + if sys.platform == 'win32': + if str(e) == "'module' object has no attribute 'AF_UNIX'": + log.error('No docker host environment variables specified. ' + 'Run docker-machine env --help for more info.') + sys.exit(1) + else: + raise def setup_logging():