How to securely connect to docker running on a remote host

How to securely connect to docker running on a remote host

One of the main challenges with developing on a Windows machine is docker support. It's just not as good as yet as it is on Linux. If you have access to a remote host that runs docker daemon that you can leverage, or you want to monitor or control docker on a remote host from you local machines, there are few options. And it's not difficult at all!

The first was is documented here. That may be good for lab and non-production environments or if you don't really care much about security of the machine (maybe it's a temporary VM you just provisioned for a quick job).

However, another quick and secure way is to tunnel over SSH which is RELATIVELY more secure than the previous option and doesn't require any setup on the docker daemon side, especially if you already have an SSH connection to the remote daemon setup.

On WSL, export DOCKER_HOST=ssh://user@host

Then run docker info. If you have an SSH key and passphrase setup on you local machine to connect to that machine, you will be prompted for it and the command will execute on the remote host.

The above will only setup your current shell session to communicate with the remote docker daemon. If you want to make this a persistent setup, export that line to your .bashrc file so that it applies to every session you create from that point on.

Show Comments