I use Docker a lot in my development lifecycle and like to manage my hosts with Docker Machine, a powerful tool for provisoining and managing your Dockerised hosts with
Docker Machine has a driver plugin architecture and the generic driver is useful if you are using a provider that it does not support directly or if you would like to import an existing host.
This is how I go about adding my existing host(s).
adduser to add new user on remote host.
Add password-less sudo priviledges
visudo to add new configuration file on remote host.
$USER ALL=(ALL) NOPASSWD:ALL. Save and exit.
Configure Key-based Authentication
On your localhost, generate a SSH key pair.
Copy your public key to remote host using
To create a machine, specify
--driver generic, the IP address or DNS name of the host and the path to the SSH private key authorized to connect to the host.
When the machine is created, Docker generates a unique SSH key and stores it in
~/.docker/machines. This is used under the hood to access the host directly with the
docker-machine ssh command.
docker-machine commands to inspect
docker-machine inspect REMOTE_HOST lists the machine details.
eval $(docker-machine env REMOTE_HOST) to connect to you
REMOTE_HOST and execute
eval $(docker-machine env -u) to disconnect.
Hope someone finds this helpful.