machine icon indicating copy to clipboard operation
machine copied to clipboard

Attach to existing machine from another client

Open AlexZeitler opened this issue 11 years ago • 85 comments

Lets consider I created a machine on Digital Ocean running some containers. After creating the machine, I can run eval "$(docker-machine env test-machine)" Now I'm moving to another local computer which does not know about that particular machine and I want to attach to that machine. How do I do that?

AlexZeitler avatar Jun 08 '15 11:06 AlexZeitler

:+1:

Oliboy50 avatar Jun 08 '15 12:06 Oliboy50

How about adding it to the 2nd system using the 'generic' driver, and then use the same eval command there?

clnperez avatar Jun 10 '15 21:06 clnperez

@clnperez is this a proposal or something you're confident that it work (means that will reuse the existing remote machine even if currently running)?

Oliboy50 avatar Jun 10 '15 21:06 Oliboy50

Well, in hindsight, I don't think you can do this b/c you'd have to set up the ssh keys again, or import them from your other system.

clnperez avatar Jun 10 '15 22:06 clnperez

I see your case. One can't add a docker-machine entry on the second system using the generic driver unless you want to invalidate the original docker-machine setup (since e.g. new creds are generated). One may run docker-machine create -d none --url [...] on the second system mirroring important options (like the swarm flags) from the original create on the first system and then manually copying selected .pem files and the id_rsa file from the first machine to the second machine AND manually add sections for SSH access (and manually change the driver to generic from none). It is a PITA. A proper export/import function would be nice to allow sharing. One can also share just the cred files needed to manually configure docker.

ljrittle avatar Jun 10 '15 23:06 ljrittle

Correct. The only current way would be to take the entire directory but this won't work with some drivers (i.e. VirtualBox because it registers VMs and networks with UUIDs that would not match). There has been discussion around an import/export feature in the past (https://github.com/docker/machine/issues/23)

ehazlett avatar Jun 11 '15 14:06 ehazlett

I have a PR/hacky solution to this in the wings... Generally I think I want to move config over to being portable / templated instead of hardcoded like things are now.

nathanleclaire avatar Jul 06 '15 22:07 nathanleclaire

+1

I would love to be able to quickly reconnect to cloud instances (I'm using GCE) that already exist.

Certainly having importable/exportable configs would be very useful, but I wonder if (additionally) addressing the issue as a driver concern might not yield a simpler user experience.

That way, using the google driver, one could connect to an existing instance on an alternate computer simply by providing a valid access-token (which the driver may prompt the user to generate automatically).

Similarly, when using the aws driver for instance, (which I have yet to do myself, but I presume) one could connect to an existing instance by providing a valid key/secret pair (perhaps through environment variables corresponding to the relevant driver-specific flags -- assuming that the process will occur through some docker-machine subcommand other than "create", since the expectations are a bit different).

jcmoore avatar Jul 13 '15 05:07 jcmoore

Just want to chime in that this would be a really great feature to have. I'd really like to be able to share a machine with my teammates and was disappointed to find out there was basically no way of doing this right now. It'd be awesome if, e.g. the generic driver could automatically detect whether a particular box had already been provisioned with docker-machine and re-use tls certs, etc. when someone ran docker-machine create on that box again.

robwhess avatar Jul 29 '15 00:07 robwhess

:+1 . I would love to see it working. Currently we are co-managing the same machines (on Google Compute Engine) with another person and the only way I found working is to copy the whole directory (+ change the absolute links in the config.json file). That's lame. I think generic driver cannot be used easily this way - there is an issue of authentication of course (tls certs etc.) cannot be simply re-used when you run --create with generic driver (somehow you need to authenticate and prove that you have access to the machine which is different for every driver - in GCE you'd have to check if your gcloud authentication allows you to access the machine). Also there is a small issue that unless you already created the machine before with given driver, your authentication piece is missing (the only way to authenticate is to .. create machine).

What I think is the best solution is to have "import" command (with different implementation for different drivers). For example in GCE, you could store all necessary details (keys etc.) somewhere in meta-data of the machine: https://cloud.google.com/compute/docs/metadata?hl=en#project_and_instance_metadata and then via specifying the project/machine name (and authenticating) you could get all the necessary keys and setup the machine.

potiuk avatar Aug 13 '15 11:08 potiuk

I would really appreciate this feature!

miguelpuyol avatar Aug 25 '15 13:08 miguelpuyol

@potiuk Which directory do you copy?

AlexZeitler avatar Aug 31 '15 17:08 AlexZeitler

@AlexZeitler ~/.docker/machine/machines/<machinename>

AlexZeitler avatar Sep 02 '15 19:09 AlexZeitler

+1!

vovimayhem avatar Oct 03 '15 03:10 vovimayhem

+1 I'd love to see a solution for this, too :-)

goloroden avatar Oct 03 '15 22:10 goloroden

I ran in exactly that problem today to give access to a colleague.

olibob avatar Oct 13 '15 17:10 olibob

+1 !!!!!

uptownhr avatar Oct 13 '15 21:10 uptownhr

Seems to be a duplicate of #23, right? Almost 1 year since we talk about this feature, some have tried to make PRs for it, but they were closed... Hope this feature will be on the next (major) release :)

Oliboy50 avatar Oct 14 '15 00:10 Oliboy50

This is absolutely required in continuous delivery scenarios, where you want to deploy using those keys from Travis or Circle CI. Any clue regarding ETA?

rbabayoff avatar Oct 16 '15 04:10 rbabayoff

gotta give this a +1 as well

bhurlow avatar Nov 08 '15 02:11 bhurlow