|
| 1 | +--- |
| 2 | +description: Hetzner Cloud driver for machine |
| 3 | +keywords: machine, hetzner, Hetzner Cloud, driver |
| 4 | +title: Hetzner Cloud |
| 5 | +--- |
| 6 | + |
| 7 | +Create Docker machines on [Hetzner Cloud](https://docs.hetzner.cloud/). |
| 8 | + |
| 9 | +You need to create a project-sepcific access token under `Access` > `API Tokens` in the project control panel |
| 10 | +and pass that to `docker-machine create` with the `--hetzner-api-token` option. |
| 11 | + |
| 12 | +## Usage |
| 13 | + |
| 14 | + $ docker-machine create --driver hetzner --hetzner-api-token=QJhoRT38JfAUO037PWJ5Zt9iAABIxdxdh4gPqNkUGKIrUMd6I3cPIsfKozI513sy some-machine |
| 15 | + |
| 16 | +### Using environment variables |
| 17 | + |
| 18 | + $ HETZNER_API_TOKEN=QJhoRT38JfAUO037PWJ5Zt9iAABIxdxdh4gPqNkUGKIrUMd6I3cPIsfKozI513sy HETZNER_IMAGE=centos-7 docker-machine create --driver hetzner some-machine |
| 19 | + |
| 20 | + |
| 21 | +## Options |
| 22 | + |
| 23 | +- `--hetzner-api-token`: **required**. Your project-specific access token for the Hetzner CLoud API. |
| 24 | +- `--hetzner-image`: The name of the Hetzner Cloud image to use, see [Images API](https://docs.hetzner.cloud/#resources-images-get) for how to get a list. |
| 25 | +- `--hetzner-server-type`: The type of the Hetzner Cloud server, see [Server Types API](https://docs.hetzner.cloud/#resources-server-types-get) for how to get a list. |
| 26 | +- `--hetzner-server-location`: The location to create the server in, see [Locations API](https://docs.hetzner.cloud/#resources-locations-get) for how to get a list. |
| 27 | +- `--hetzner-existing-key-path`: Use an existing (local) SSH key instead of generating a new keypair. |
| 28 | +- `--hetzner-existing-key-id`: **requires `--hetzner-existing-key-path`**. Use an existing (remote) SSH key instead of uploading the imported key pair, |
| 29 | + see [SSH Keys API](https://docs.hetzner.cloud/#resources-ssh-keys-get) for how to get a list |
| 30 | + |
| 31 | +The Hetzner Cloud driver will use `debian-9` as the default image and `g2-local` as the default type. |
| 32 | + |
| 33 | +#### Existing SSH keys |
| 34 | + |
| 35 | +When you specify the `--hetzner-existing-key-path` option, the driver will attempt to copy the `*(specified file name)*` |
| 36 | +and `*(specified file name).pub*` to the machine's store path. They public key file's permissions will be set according |
| 37 | +to your current `umask` and the private key file will have `600` permissions. |
| 38 | + |
| 39 | +When you additionally specify the `--hetzner-existing-key-id` option, the driver will not create an SSH key using the API |
| 40 | +but rather try to use the existing public key corresponding to the given id. Please note that during machine creation, |
| 41 | +the driver will attempt to [get the key](https://docs.hetzner.cloud/#resources-ssh-keys-get-1) and **compare it's |
| 42 | +fingerprint to the local public key's fingerprtint**. Keep in mind that the both the local and the remote key must be |
| 43 | +accessible and have matching fingerprints, otherwise the machine will fail it's pre-creation checks. |
| 44 | + |
| 45 | +Also note that the driver will attempt to delete the linked key during machine removal, unless `--hetzner-existing-key-id` |
| 46 | +was used during creation. |
| 47 | + |
| 48 | +#### Environment variables and default values |
| 49 | + |
| 50 | +| CLI option | Environment variable | Default | |
| 51 | +| ----------------------------------- | --------------------------------- | -------------------------- | |
| 52 | +| **`--hetzner-api-token`** | `HETZNER_API_TOKEN` | - | |
| 53 | +| `--hetzner-image ` | `HETZNER_IMAGE_IMAGE` | `debian-9` | |
| 54 | +| `--hetzner-server-type` | `HETZNER_TYPE` | `g2-local` | |
| 55 | +| `--hetzner-server-location` | `HETZNER_LOCATION` | - *(let Hetzner choose)* | |
| 56 | +| `--hetzner-existing-key-path` | `HETZNER_EXISTING_KEY_PATH` | - *(generate new keypair)* | |
| 57 | +| `--hetzner-existing-key-id` | `HETZNER_EXISTING_KEY_ID` | 0 *(upload new key)* | |
0 commit comments