Repository: docker/docker-py

Issue:
Windows: remote docker context via SSH fails on Windows
This bug-causing code was added in PR #2691 

https://github.com/aiordache/docker-py/blob/f5531a94e1096f4c8456264f6511dfe89e1c825e/docker/transport/sshconn.py#L50

causes docker-compose fail on all commands when using a remote context using SSH on windows.

SDK Version: 4.4.0
OS version: Windows 10 2004 Build 19041.630
Docker-compose version: 1.28.0-rc1

<details>
  <summary>docker version</summary>

```
Client:
 Version:           19.03.12
 API version:       1.40
 Go version:        go1.13.12
 Git commit:        0ed913b8-
 Built:             07/28/2020 16:36:03
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.14
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       5eb3275d40
  Built:            Tue Dec  1 19:18:53 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.3.9
  GitCommit:        ea765aba0d05254012b0b9e595e995c09186427f
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
```

</details>


<details>
  <summary>docker-compose version</summary>

```
docker-compose version
docker-compose version 1.28.0-rc1, build 1f469474
docker-py version: 4.4.0
CPython version: 3.9.0
OpenSSL version: OpenSSL 1.1.1g  21 Apr 2020
```

</details>


<details>
  <summary>Error thrown</summary>

```
PS C:\Users\....\Documents\Projects\....> $env:COMPOSE_PARAMIKO_SSH="0" && docker-compose ps
Traceback (most recent call last):
  File "docker\api\client.py", line 214, in _retrieve_server_version
  File "docker\api\daemon.py", line 181, in version
  File "docker\utils\decorators.py", line 46, in inner
  File "docker\api\client.py", line 237, in _get
  File "requests\sessions.py", line 543, in get
  File "requests\sessions.py", line 530, in request
  File "requests\sessions.py", line 643, in send
  File "requests\adapters.py", line 439, in send
  File "urllib3\connectionpool.py", line 670, in urlopen
  File "urllib3\connectionpool.py", line 392, in _make_request
  File "http\client.py", line 1255, in request
  File "http\client.py", line 1301, in _send_request
  File "http\client.py", line 1250, in endheaders
  File "http\client.py", line 1010, in _send_output
  File "http\client.py", line 950, in send
  File "docker\transport\sshconn.py", line 105, in connect
  File "docker\transport\sshconn.py", line 45, in connect
  File "subprocess.py", line 778, in __init__
ValueError: preexec_fn is not supported on Windows platforms

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose\cli\main.py", line 68, in main
  File "compose\cli\main.py", line 124, in perform_command
  File "compose\cli\command.py", line 60, in project_from_options
  File "compose\cli\command.py", line 152, in get_project
  File "compose\cli\docker_client.py", line 41, in get_client
  File "compose\cli\docker_client.py", line 170, in docker_client
  File "docker\api\client.py", line 197, in __init__
  File "docker\api\client.py", line 221, in _retrieve_server_version
docker.errors.DockerException: Error while fetching server API version: preexec_fn is not supported on Windows platforms
[580] Failed to execute script docker-compose
```

</details>





Discussion:

Resolving patch:
diff --git a/docker/transport/sshconn.py b/docker/transport/sshconn.py
--- a/docker/transport/sshconn.py
+++ b/docker/transport/sshconn.py
@@ -42,12 +42,17 @@ def connect(self, **kwargs):
             port,
             'docker system dial-stdio'
         ]
+
+        preexec_func = None
+        if not constants.IS_WINDOWS_PLATFORM:
+            preexec_func = lambda: signal.signal(signal.SIGINT, signal.SIG_IGN)
+
         self.proc = subprocess.Popen(
             ' '.join(args),
             shell=True,
             stdout=subprocess.PIPE,
             stdin=subprocess.PIPE,
-            preexec_fn=lambda: signal.signal(signal.SIGINT, signal.SIG_IGN))
+            preexec_fn=preexec_func)
 
     def _write(self, data):
         if not self.proc or self.proc.stdin.closed:


Test patch: