Let’s attempt to use SSH port forwarding to tunnel a remote Docker host to out local machine, granting us access to resources as if they are running locally.
First tunnel remote socket to a port on local machine.
ssh -nNT -L localhost:2345:/var/run/docker.sock [email protected]
n prevents reading from stdin,
N does not execute any command and
T will not allocate a PTY.
Next open a new terminal and export DOCKER_HOST.
While using this terminal, local docker commands are executed on remote server.