How can I attach docker-machine to an existing Droplet created with another docker-machine?

Posted September 8, 2015 13.1k views

I have some Docker swarm masters and agents I’ve created using my docker-machine client, but I want a way to allow a trusted colleague to attach his local docker-machine installation to the same hosts. Is this possible?

1 comment
  • Almost the same peoblem:

    I’ve created a droplet via the web site not using docker machine.

    Is it possible to attach docker machine to this droplet?


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

I have a Docker droplet that I made not through Docker Machine, but this worked for me, and it should work for your use case:

Docker Machine has a generic driver that you can use to connect to an existing Docker remote host (replace the stubbed placeholders with your info):

docker-machine create \
    --driver=generic \
    --generic-ip-address=IP_ADDRESS \
    --generic-ssh-user=USERNAME \
    --generic-ssh-key=PATH_TO_SSH_KEY \
    --generic-ssh-port=PORT \

You need to be able to SSH in with the key you provide for it to connect. Also, you’ll need to make sure port 2376 is open (ufw allow 2376 in Debian/Ubuntu) and that you can use passwordless sudo (add %sudo ALL=(ALL) NOPASSWD:ALL to /etc/sudoers).


Unfortunately, this isn’t very straight forward at the moment. There are some proposals for ways to simplify share machines between users in the future, but for now you would need to share your docker-machine configuration files from the ~/.docker/machine/ directory.