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

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?

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.