瀏覽代碼

Merge pull request #3436 from shin-/3374-exec-windows

Fail gracefully when -d is not provided for exec command on Win32
Joffrey F 9 年之前
父節點
當前提交
ca3aef0c84
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      compose/cli/main.py

+ 8 - 1
compose/cli/main.py

@@ -334,6 +334,13 @@ class TopLevelCommand(object):
         """
         index = int(options.get('--index'))
         service = self.project.get_service(options['SERVICE'])
+        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:
             container = service.get_container(number=index)
         except ValueError as e:
@@ -350,7 +357,7 @@ class TopLevelCommand(object):
 
         exec_id = container.create_exec(command, **create_exec_options)
 
-        if options['-d']:
+        if detach:
             container.start_exec(exec_id, tty=tty)
             return