Search code examples
network-programmingdockersshdocker-network

Configuring docker to communicate over the network


I have remote machine. I enter into it in two steps:

1) ssh -A login@server.com

Then inside this machine I enter into my remote machine:

2)ssh -A mymachine

This remote machine doesn't have a public IP which I can specify in DOCKER_HOST=xx.xx.xx.xx.

How can I configure my docker in such way that my laptop would have a docker client and that remote machine would have docker server daemon?


Solution

  • The docker client/server API needs a reachable API. Just as you can't run a web server on mymachine and access it with a web browser on your laptop, you can't configure DOCKER_HOST without an IP you can reach.

    Your options that I can think of include:

    • Run your commands remotely, either on mymachine or on server.com.
    • Setup a VPN that gives your laptop an IP that can reach mymachine
    • Use ssh port forwarding to make a tunnel which you can point your DOCKER_HOST to. e.g. ssh -L 2376:mymachine:2376 login@server.com and then export DOCKER_HOST=localhost:2376 (I haven't tested this, and it requires sshd to permit the option).