Specify Docker host using ssh://
schema
docker --host ssh://[<user>@]<host> version
SSH agent should be used for authentication
Added in Docker 18.09
Required on server and client
Test containerized
Run SSH agent:
eval $(ssh-agent -s)
ssh-add .ssh/id_rsa
Authorise SSH key:
cp ./.ssh/id_rsa.pub ./.ssh/authorized_keys
Run container with Docker and SSH:
docker run --name ssh \
--detach \
--privileged \
remoting-ssh
Forward Docker socket through SSH:
ssh -fNL $HOME/.docker.sock:/var/run/docker.sock user@host
Use forwarded socket:
docker --host unix://$HOME/.docker.sock version