Score:2

Docker-compose can't connect via socks-proxy to SSH remote host

au flag

I'm trying to deploy containers using docker-compose to remote server via SSH. Remote server SSH can be accessed only via SOCKS proxy. I created ~/.ssh/config with valid SOCKS configuration for that:

Host <my.host>
  HostName <my.host>
  ProxyCommand socks-connect -S <socks-user>@<socks-host>:<socks-port> %h %p
  Port <ssh-port>
  User <ssh-user>
  IdentityFile ~/.ssh/<ssh-key>

This config is working fine: I can connect via proxy using ssh <my.host> command.

Then I created Docker context, and tested it:

$ docker context create remote --docker "host=ssh://<my.host>"
$ docker --context=remote ps
<list of running containers on remote host>

But when I try to use this context with docker-compose, it fails with error:

$ docker-compose --context=remote --verbose ps
ERROR: Got error response from SOCKS server: 4 (Host unreachable)
FATAL: failed to begin relaying via SOCKS
kex_exchange_identification: Connection closed by remote host

Also, I tried using DOCKER_HOST environment but got the same error: env DOCKER_HOST="ssh://<my-host>" docker-compose ps.

So it seems the problem is in docker-compose because pure docker commands works correctly. What could be the problem here and how can I fix this behavior?

Docker client version: 20.10.7
Docker server version (remote): 19.03.12
Docker compose version: 1.29.2

Score:0
cn flag

Looks like ssh method did not check ~/.ssh/config, there is another way by forward remote docker sock to local tcp port:

https://code.visualstudio.com/docs/remote/troubleshooting#_using-an-ssh-tunnel-to-connect-to-a-remote-docker-host

ssh -NL localhost:23750:/var/run/docker.sock user@hostname

Then:

DOCKER_HOST="tcp://localhost:23750" docker-compose build
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.