JonasProgrammer / docker-machine-driver-hetzner

Docker machine driver for the new hetzner cloud API
https://jonasprogrammer.github.io/docker-machine-driver-hetzner/
MIT License
434 stars 54 forks source link

Using ID to define hetzner image #14

Closed kaotika closed 6 years ago

kaotika commented 6 years ago

Hi, many thanks for the driver!

I want to provision a new server with an snapshot image instead of a system image. You could create a custom image than (I tried CoreOS) and use it as the basis for other servers.

The problem: snapshot images are listed by the API, but don't have a name (it's null) and can't be used with docker-machine. Is it possible to use the ID of an image instead of just the name? Maybe some new option --hetzner-image-id xyz?

JonasProgrammer commented 6 years ago

Should work as of version 1.2.0. Could you test it in your usecase please?

kaotika commented 6 years ago

Wow, this was very fast! :smile:

It seem to work like expected. I just stuck in a process, where it askes for a password and doesn't accepts any of mine. But I thinks it has to do with the image rather then the driver.

Thanks!

JonasProgrammer commented 6 years ago

Well, server creation doesn't seem to "import" new keys for servers created from snapshots. I also got stuck at this point when testing (mostly due to not having an SSH key at all on the test server I took the snapshot of), but I assumed that the server being created is enough to consider this 'working'.

Perhaps you could manually create a server from your snapshot, add a pregenerated SSH key to it and then use --existing-key-path? Please note, you have to upload the key to hetzner as well and specify it's ID in order for that flag to work.

I might try and overhaul the key system as well, as it's current form emerged from the beta days and was never designed with snapshots in mind. But for now, it'd be really helpful if you could tell, if the workaround I described above works, at least.

kaotika commented 6 years ago

The workaround doen't seem to work. I only managed to add the server to my local config using -d none docker-machine create -d none --url tcp://a.b.c.d:2376 snapshot-test. Creating it with a full create and --hetzner-existing-key-path doesn't worked (The syntax was correct. I checked it with an ubuntu image). I always got: Error creating machine: Error in driver during machine creation: could not create server: server name is already used (uniqueness_error)

JonasProgrammer commented 6 years ago

Have you run docker machine rm -f before? Also please double-check in the cloud console, that the name you give to the machine is not already in use as a server name. To me at least, the error message seems unrelated to the original problem.

kaotika commented 6 years ago

Yes, there was no identically named server in the cloud console and non in my local config.

I tried the following steps:

JonasProgrammer commented 6 years ago

I'm sorry, but I cannot reproduce this at all. docker-machine create -d hetzner --hetzner-api-token REDACTED --hetzner-image-id 1502xx --hetzner-existing-key-id 401xx --hetzner-existing-key-path ./testkey hdm-test works perfectly fine for me [well, provisioning fails when it tries to start docker, but that's another story]. Granted, I used a fresh debian cloud server and took a snapshot right away, but your error message still looks like it is another unrelated problem.

Can you please try a different name for the server? Also could you generate a fresh keypair for the trial? Besides, docker-machine copies the private key all over the place, perhaps you shouldn't use your id_rsa.

JonasProgrammer commented 6 years ago

Closing due to lack of input. If you've still got problems regarding snapshot propagation, feel free to re-open.