2

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

g4s8
  • 121
  • 3

1 Answers1

0

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
linjunhalida
  • 141
  • 5