Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

Attach to existing machine from another client #1328

Open
AlexZeitler opened this issue Jun 8, 2015 · 85 comments
Open

Attach to existing machine from another client #1328

AlexZeitler opened this issue Jun 8, 2015 · 85 comments

Comments

@AlexZeitler
Copy link

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?

@Oliboy50
Copy link

Oliboy50 commented Jun 8, 2015

👍

@clnperez
Copy link
Contributor

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

@Oliboy50
Copy link

@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)?

@clnperez
Copy link
Contributor

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.

@ljrittle
Copy link

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.

@ehazlett
Copy link
Contributor

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 (#23)

@nathanleclaire
Copy link
Contributor

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.

@jcmoore
Copy link

jcmoore commented Jul 13, 2015

+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).

@robwhess
Copy link

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.

@potiuk
Copy link

potiuk commented Aug 13, 2015

:+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.

@miguelpuyol
Copy link

I would really appreciate this feature!

@AlexZeitler
Copy link
Author

@potiuk Which directory do you copy?

@AlexZeitler
Copy link
Author

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

@vovimayhem
Copy link

+1!

@goloroden
Copy link

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

@olibob
Copy link

olibob commented Oct 13, 2015

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

@uptownhr
Copy link

+1 !!!!!

@Oliboy50
Copy link

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 :)

@rbabayoff
Copy link

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?

@bhurlow
Copy link

bhurlow commented Nov 8, 2015

gotta give this a +1 as well

@micheletedeschi
Copy link

+1

@jbasrai
Copy link

jbasrai commented Dec 8, 2015

+1

Is there anything you have to do besides copying the ~/.docker/machine/machines/<name> folder and changing the absolute paths? I get an error message related to my certs, and attempting to regenerate them fails as well.

@nathanleclaire
Copy link
Contributor

@jbasrai Did the IP of what you're trying to access change?

@nathanleclaire
Copy link
Contributor

I've filed #2516 to start considering steps in the right direction to make this easier.

@jbwinters
Copy link

This is a vital feature, and I'd love to see it in a near-future release. In my opinion machine configuration should remain unique to a client, not be imported/exported. Instead (as others have mentioned) docker-machine create run with the same arguments should be able to create a configuration for the machine even if it already exists remotely instead of failing like it does now. When re-running my create command for an existing amazonec2 machine, I get this error telling me that the host already exists:

Error creating machine: Error with pre-create check: There is already a keypair with the name testing-recreate.  Please either remove that keypair or use a different machine name.

Instead it might warn me that the host already exists and continue to add the machine as it would in an initial creation (perhaps requiring that an override flag be passed). That way I can keep my dev/CI environment set-up scripts simple and not worry about having to store this configuration somewhere that my teammates (or other parties) can access it.

@thib-rdr
Copy link

thib-rdr commented Feb 4, 2016

It is indeed astonishing that for multiple persons to work on the same vm, we have to export/import certificates from one machine to another. If someone found a practical, production-ready solution, that would be good to know.

@Pierre-Gilles
Copy link

+1

1 similar comment
@rm25282
Copy link

rm25282 commented Feb 5, 2016

+1

@davad
Copy link

davad commented Mar 10, 2017 via email

@ifeltsweet
Copy link

+1

7 similar comments
@AshleyAitken
Copy link

+1

@inakrin
Copy link

inakrin commented Apr 16, 2017

+1

@moritzschaefer
Copy link

+1

@ewianda
Copy link

ewianda commented Apr 23, 2017

+1

@HarenBroog
Copy link

+1

@kcavagnolo
Copy link

+1

@lukin0110
Copy link

+1

@apk
Copy link

apk commented May 25, 2017

docker-machine attach, please.

It's pretty remarkable that such an obvious functionality still does not exist out of the box. We're going to jointly administer docker hosts, and this is such a nuisance.

@cybertk
Copy link

cybertk commented Jun 16, 2017

In my case, very happy to attach existing host ${HOST} with

docker-machine --tlscacert=ca.pem --tlscert=cert.pem --tlskey=key.pem create \
    --drive none --url tcp://${HOST}:2376

But need copy certificates(ca.pem, cert.pem, key.pem) to DOCKER_CERT_PATH manually.

@lyda
Copy link

lyda commented Jul 20, 2017

Any plans for this? Having full paths recorded in config.json is frustrating.

My use case: I have a git repo with machine configs in in it (I use the -s to point docker-machine into it). Secrets are stored with git encrypt and the idea is for CI jobs to be able to make use of these configs to manipulate the machines they need to access.

@lnshi
Copy link

lnshi commented Sep 7, 2017

FYI: #3212

@schmunk42
Copy link

@lyda We're using such an approach with https://github.com/dmstr/docker-roj - but without encryption, which would be a very nice feature actually!

While roj always works with the same paths, since it's in a container, there are other solutions like:

which basically change a few paths in the config.json.
It's no big magic, unless I am totally missing something here.

@montanaflynn
Copy link

Is docker-machine being actively developed by docker? I ask because it's been over a month since a commit made it to master: https://github.com/docker/machine/commits/master

@vibhuyadav
Copy link

+1

2 similar comments
@amihura
Copy link

amihura commented Jan 4, 2018

+1

@pvlg
Copy link

pvlg commented Jan 16, 2018

+1

@jcheroske
Copy link

My god, the horror! This thread is still alive after almost three years?!? This is a use-case that everyone bumps into, or would seem to. What am I missing?

@HarenBroog
Copy link

HarenBroog commented Jan 31, 2018

Well I assume docker-machine is dead (at least for me :D). I switched to kubernetes. Even self hosted kubeadm in alfa version works better that this actually. I can recommend it :)

@ivoribeiro
Copy link

please support this :(

@brandontamm
Copy link

add "~/.docker" to a folder that is rsynced or maybe symbolic linked to cloud folder on both machines. there are a couple pre-built solutions. not too hard guys, just do some research - never had an issue after setting up one time for 30 seconds.

@dbroeh
Copy link

dbroeh commented Mar 13, 2018

+1

1 similar comment
@philippreston
Copy link

+1

@gnat
Copy link

gnat commented Sep 25, 2018

How this feature, as well as specifying a static IP--- the two most requested features in the history of the docker-machine project--- goes unimplemented is beyond me.

@bluesurfer
Copy link

Almost 4 years have passed 😮 Are there any update on this?

At the moment, many articles/tutorials about Docker are still suggesting to use docker-machine as the de-facto tool to manage hosts. However, this issue presence is a strong limiting factor!

I am currently keep using docker-machine and use the “copy-certs-dirs” approach to share between our local computers. I would like to upgrade to Kubernetes but it looks just too much for my project.

@teggno
Copy link

teggno commented Feb 27, 2019

How about running docker-machine create from within a docker container? That container could then be exported, imported on another computer and then run there.

@rafaelbrier
Copy link

Still doesn't have an attach, oh my god

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests