compose icon indicating copy to clipboard operation
compose copied to clipboard

compose up via SSH fails with ERROR: Secsh channel 21 open FAILED: open failed: Connect failed

Open tze opened this issue 6 years ago • 4 comments

Description of the issue

Trying to start an application via compose over SSH fails after a random number of services (or none) from the compose file were started successfully.

Context information (for bug reports)

Output of docker-compose version

docker-compose version 1.26.2, build eefe0d31
docker-py version: 4.2.2
CPython version: 3.7.4
OpenSSL version: OpenSSL 1.1.1c  28 May 2019

Output of docker version

Client: Docker Engine - Community
 Version:           19.03.12
 API version:       1.40
 Go version:        go1.13.10
 Git commit:        48a66213fe
 Built:             Mon Jun 22 15:43:18 2020
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.12
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.10
  Git commit:       48a66213fe
  Built:            Mon Jun 22 15:49:27 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker-compose config (Make sure to add the relevant -f and other flags)

services:
  backend:
    image: company/backend:latest
    volumes:
    - /tmp/company-docker/logs/backend:/opt/app/log:rw
  frontend:
    image: company/frontend:latest
    volumes:
    - /tmp/company-docker/logs-frontend:/var/log/nginx:rw
  proxy:
    depends_on:
    - backend
    - frontend
    image: company/proxy:latest
    ports:
    - published: 58010
      target: 80
version: '3.8'

Steps to reproduce the issue

  1. compose file with multiple containers
  2. Start on remote host via SSH

Observed result

Compose file contains three services, sometimes the error occurs for the first service. In the following occurrence it happened to work for the first 2/3. However it never works for 3/3.

Expected result

All services are started.

Stacktrace / full error message

$ DOCKER_HOST="ssh://user@host" docker-compose -p project --env-file production.env up
project_frontend_1 is up-to-date
Starting project_backend_1 ... done
Creating project_proxy_1   ... 
ERROR: Secsh channel 21 open FAILED: open failed: Connect failed

ERROR: for project_proxy_1  ChannelException(2, 'Connect failed')

ERROR: for proxy  ChannelException(2, 'Connect failed')
Traceback (most recent call last):
  File "docker-compose", line 6, in <module>
  File "compose\cli\main.py", line 72, in main
  File "compose\cli\main.py", line 128, in perform_command
  File "compose\cli\main.py", line 1078, in up
  File "compose\cli\main.py", line 1074, in up
  File "compose\project.py", line 576, in up
  File "compose\parallel.py", line 112, in parallel_execute
  File "compose\parallel.py", line 210, in producer
  File "compose\project.py", line 562, in do
  File "compose\service.py", line 547, in execute_convergence_plan
  File "compose\service.py", line 468, in _execute_convergence_create
  File "compose\parallel.py", line 112, in parallel_execute
  File "compose\parallel.py", line 210, in producer
  File "compose\service.py", line 466, in <lambda>
  File "compose\service.py", line 458, in create_and_start
  File "compose\service.py", line 624, in start_container
  File "compose\service.py", line 660, in connect_container_to_networks
  File "site-packages\docker\utils\decorators.py", line 19, in wrapped
  File "site-packages\docker\api\network.py", line 248, in connect_container_to_network
  File "site-packages\docker\api\client.py", line 289, in _post_json
  File "site-packages\docker\utils\decorators.py", line 46, in inner
  File "site-packages\docker\api\client.py", line 226, in _post
  File "site-packages\requests\sessions.py", line 581, in post
  File "site-packages\requests\sessions.py", line 533, in request
  File "site-packages\requests\sessions.py", line 646, in send
  File "site-packages\requests\adapters.py", line 449, in send
  File "site-packages\urllib3\connectionpool.py", line 677, in urlopen
  File "site-packages\urllib3\connectionpool.py", line 392, in _make_request
  File "http\client.py", line 1244, in request
  File "http\client.py", line 1290, in _send_request
  File "http\client.py", line 1239, in endheaders
  File "http\client.py", line 1026, in _send_output
  File "http\client.py", line 966, in send
  File "site-packages\docker\transport\sshconn.py", line 32, in connect
  File "site-packages\paramiko\transport.py", line 879, in open_session
  File "site-packages\paramiko\transport.py", line 1017, in open_channel
paramiko.ssh_exception.ChannelException: ChannelException(2, 'Connect failed')
[5300] Failed to execute script docker-compose

Additional information

OS version / distribution, docker-compose install method, etc.

tze avatar Sep 10 '20 14:09 tze

I've been sporadically running into this with Debian hosts & containers when using remote context via SSH. Seems there was an existing ticket for this issue with a fix but the merge may have been missed.

fletchowns avatar Feb 07 '21 02:02 fletchowns

I get a similar issue using remote context via SSH into my Pi4. Happens on up and down.

$ docker-compose --context pi4 down Stopping hueshift2 ... done Stopping watchtower ... done Removing hueshift2 ... Removing watchtower ... Removing watchtower ... done

ERROR: for hueshift2 ChannelException(2, 'Connect failed') Traceback (most recent call last): File "docker-compose", line 3, in File "compose\cli\main.py", line 67, in main File "compose\cli\main.py", line 126, in perform_command File "compose\cli\main.py", line 422, in down File "compose\project.py", line 405, in down File "compose\project.py", line 393, in remove_stopped File "compose\parallel.py", line 337, in parallel_remove File "compose\parallel.py", line 331, in parallel_operation File "compose\parallel.py", line 108, in parallel_execute File "compose\parallel.py", line 206, in producer File "compose\container.py", line 255, in remove File "site-packages\docker\utils\decorators.py", line 19, in wrapped File "site-packages\docker\api\container.py", line 1007, in remove_container File "site-packages\docker\utils\decorators.py", line 46, in inner File "site-packages\docker\api\client.py", line 236, in _delete File "site-packages\requests\sessions.py", line 612, in delete File "site-packages\requests\sessions.py", line 530, in request File "site-packages\requests\sessions.py", line 643, in send File "site-packages\requests\adapters.py", line 449, in send File "site-packages\urllib3\connectionpool.py", line 677, in urlopen File "site-packages\urllib3\connectionpool.py", line 392, in _make_request File "http\client.py", line 1244, in request File "http\client.py", line 1290, in _send_request File "http\client.py", line 1239, in endheaders File "http\client.py", line 1026, in _send_output File "http\client.py", line 966, in send File "site-packages\docker\transport\sshconn.py", line 32, in connect File "site-packages\paramiko\transport.py", line 879, in open_session File "site-packages\paramiko\transport.py", line 1017, in open_channel paramiko.ssh_exception.ChannelException: ChannelException(2, 'Connect failed') [5532] Failed to execute script docker-compose

mholubinka1 avatar Feb 26 '21 12:02 mholubinka1

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 28 '21 17:08 stale[bot]

This issue has been automatically closed because it had not recent activity during the stale period.

stale[bot] avatar Sep 07 '21 05:09 stale[bot]