Docker is usually administered locally on the host it is running. The Docker client, by default, will connect to the Unix socket when communicating with the daemon. In this tutorial, you will learn how to connect the client to a remote host using SSH.
Before opening your Docker host to remote SSH connections, it is strongly advised to allow only trusted traffic.
A firewall or network policy should block all traffic to the Docker host, and whitelist traffic to trusted IPs or Subnets.
SSH Public RSA Key
Accessing a system via SSH requires a user with privileges to the Docker daemon. It also requires a public RSA key from your local user.
If you haven’t already created a key-pair, do so now
With the key-pair, copy your public key to the user of the remote host.
ssh-copy-id [email protected]
Configure Docker Daemon for SSH
Remote Docker client SSH Connection
You are finally ready to remotely administer your Docker host. Verify your access to the remote by listing running containers.
docker -H ssh://[email protected] ps
If everything was done successfully you will see a table of running containers.