X Tutup
Skip to content

Commit ed95f3b

Browse files
committed
New Microsoft Azure docker-machine driver
The new driver uses Azure Resource Manager APIs and offers a lot more functionality compared to the old Azure driver. It is also easier to authenticate and does not require user to create and place certificate files. It only has a single required argument. This is a breaking change: The new driver cannot work with machines created with the older Azure driver and vice versa (as the APIs are entirely different and resources are not shared between old/new azure APIs). The new driver addresses many issues about the azure driver reported so far. This resolves docker-archive-public#2742, resolves docker-archive-public#1368, resolves docker-archive-public#1142, resolves docker-archive-public#2236, resolves docker-archive-public#2408, resolves docker-archive-public#1126, resolves docker-archive-public#774. Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
1 parent 4d68c92 commit ed95f3b

File tree

17 files changed

+2226
-34
lines changed

17 files changed

+2226
-34
lines changed

cmd/machine.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/docker/machine/commands"
1212
"github.com/docker/machine/commands/mcndirs"
1313
"github.com/docker/machine/drivers/amazonec2"
14+
"github.com/docker/machine/drivers/azure"
1415
"github.com/docker/machine/drivers/digitalocean"
1516
"github.com/docker/machine/drivers/exoscale"
1617
"github.com/docker/machine/drivers/generic"
@@ -168,6 +169,8 @@ func runDriver(driverName string) {
168169
switch driverName {
169170
case "amazonec2":
170171
plugin.RegisterDriver(amazonec2.NewDriver("", ""))
172+
case "azure":
173+
plugin.RegisterDriver(azure.NewDriver("", ""))
171174
case "digitalocean":
172175
plugin.RegisterDriver(digitalocean.NewDriver("", ""))
173176
case "exoscale":

docs/drivers/azure.md

Lines changed: 87 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,51 +10,105 @@ parent="smn_machine_drivers"
1010

1111
# Microsoft Azure
1212

13-
Create machines on [Microsoft Azure](http://azure.microsoft.com/).
13+
You will need an Azure Subscription to use this Docker Machine driver.
14+
[Sign up for a free trial.][trial]
1415

15-
You need to create a subscription with a cert. Run these commands and answer the questions:
16+
> **NOTE:** This documentation is for the new version of Azure driver started
17+
> shipping with v0.7.0 and it is not backwards-compatible with the old Azure
18+
> driver. If you like to manage your existing Azure machines, please download
19+
> and use machine versions prior to v0.7.0.
1620
17-
$ openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem
18-
$ openssl pkcs12 -export -out mycert.pfx -in mycert.pem -name "My Certificate"
19-
$ openssl x509 -inform pem -in mycert.pem -outform der -out mycert.cer
21+
[azure]: http://azure.microsoft.com/
22+
[trial]: https://azure.microsoft.com/free/
2023

21-
Go to the Azure portal, go to the "Settings" page (you can find the link at the bottom of the
22-
left sidebar - you need to scroll), then "Management Certificates" and upload `mycert.cer`.
24+
## Authentication
2325

24-
Grab your subscription ID from the portal, then run `docker-machine create` with these details:
26+
First time you try to create a machine, Azure driver will ask you to
27+
authenticate:
2528

26-
$ docker-machine create -d azure --azure-subscription-id="SUB_ID" --azure-subscription-cert="mycert.pem" A-VERY-UNIQUE-NAME
29+
$ docker-machine create --driver azure <machine-name>
30+
Running pre-create checks...
31+
Microsoft Azure: To sign in, use a web browser to open the page https://aka.ms/devicelogin.
32+
Enter the code [...] to authenticate.
2733

28-
The Azure driver uses the `b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-15_10-amd64-server-20151116.1-en-us-30GB`
29-
image by default. Note, this image is not available in the Chinese regions. In China you should
30-
specify `b549f4301d0b4295b8e76ceb65df47d4__Ubuntu-15_10-amd64-server-20151116.1-en-us-30GB`.
34+
After authenticating, the driver will remember your credentials up to two weeks.
3135

32-
You may need to `machine ssh` in to the virtual machine and reboot to ensure that the OS is updated.
36+
## Options
3337

34-
Options:
38+
Azure driver only has a single required argument to make things easier. Please
39+
read the optional flags to configure machine details and placement further.
3540

36-
- `--azure-docker-port`: Port for Docker daemon.
37-
- `--azure-image`: Azure image name. See [How to: Get the Windows Azure Image Name](https://msdn.microsoft.com/en-us/library/dn135249%28v=nav.70%29.aspx)
38-
- `--azure-location`: Machine instance location.
39-
- `--azure-password`: Your Azure password.
40-
- `--azure-publish-settings-file`: Azure setting file. See [How to: Download and Import Publish Settings and Subscription Information](https://msdn.microsoft.com/en-us/library/dn385850%28v=nav.70%29.aspx)
41-
- `--azure-size`: Azure disk size.
42-
- `--azure-ssh-port`: Azure SSH port.
43-
- `--azure-subscription-id`: **required** Your Azure subscription ID (A GUID like `d255d8d7-5af0-4f5c-8a3e-1545044b861e`).
44-
- `--azure-subscription-cert`: **required** Your Azure subscription cert.
45-
- `--azure-username`: Azure login user name.
41+
Required:
42+
43+
- `--azure-subscription-id`: **(required)** Your Azure Subscription ID.
44+
45+
Optional:
46+
47+
- `--azure-image`: Azure virtual machine image. [[?][vm-image]]
48+
- `--azure-location`: Azure region to create the virtual machine. [[?][location]]
49+
- `--azure-resource-group`: Azure Resource Group name to create the resources in.
50+
- `--azure-size`: Size for Azure Virtual Machine. [[?][vm-size]]
51+
- `--azure-ssh-user`: Username for SSH login.
52+
- `--azure-vnet`: Azure Virtual Network name to connect the virtual machine. [[?][vnet]]
53+
- `--azure-subnet`: Azure Subnet Name to be used within the Virtual Network.
54+
- `--azure-subnet-prefix`: Private CIDR block to be used for the new subnet.
55+
- `--azure-availability-set`: Azure Availability Set to place the virtual machine into. [[?][av-set]]
56+
- `--azure-open-port`: Make additional port number(s) accessible from the Internet [[?][nsg]]
57+
- `--azure-private-ip-address`: Specify a static private IP address for the machine.
58+
- `--azure-use-private-ip`: Use private IP address of the machine to connect.
59+
- `--azure-no-public-ip`: Do not create a public IP address for the machine.
60+
- `--azure-docker-port`: Port number for Docker engine [$AZURE_DOCKER_PORT]
61+
- `--azure-environment`: Azure environment (e.g. `AzurePublicCloud`, `AzureChinaCloud`).
62+
63+
[vm-image]: https://azure.microsoft.com/en-us/documentation/articles/resource-groups-vm-searching/
64+
[location]: https://azure.microsoft.com/en-us/regions/
65+
[vm-size]: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-size-specs/
66+
[vnet]: https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-overview/
67+
[av-set]: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-manage-availability/
4668

4769
Environment variables and default values:
4870

4971
| CLI option | Environment variable | Default |
5072
| ------------------------------- | ----------------------------- | ------------------ |
51-
| `--azure-docker-port` | - | `2376` |
52-
| `--azure-image` | `AZURE_IMAGE` | _Ubuntu 15.10 x64_ |
53-
| `--azure-location` | `AZURE_LOCATION` | `West US` |
54-
| `--azure-password` | - | - |
55-
| `--azure-publish-settings-file` | `AZURE_PUBLISH_SETTINGS_FILE` | - |
56-
| `--azure-size` | `AZURE_SIZE` | `Small` |
57-
| `--azure-ssh-port` | - | `22` |
58-
| **`--azure-subscription-cert`** | `AZURE_SUBSCRIPTION_CERT` | - |
5973
| **`--azure-subscription-id`** | `AZURE_SUBSCRIPTION_ID` | - |
60-
| `--azure-username` | - | `ubuntu` |
74+
| `--azure-environment` | `AZURE_ENVIRONMENT` | `AzurePublicCloud` |
75+
| `--azure-image` | `AZURE_IMAGE` | `canonical:UbuntuServer:14.04.3-LTS:latest` |
76+
| `--azure-location` | `AZURE_LOCATION` | `westus` |
77+
| `--azure-resource-group` | `AZURE_RESOURCE_GROUP` | `docker-machine` |
78+
| `--azure-size` | `AZURE_SIZE` | `Standard_A2` |
79+
| `--azure-ssh-user` | `AZURE_SSH_USER` | `ubuntu` |
80+
| `--azure-vnet` | `AZURE_VNET` | `docker-machine` |
81+
| `--azure-subnet` | `AZURE_SUBNET` | `docker-machine` |
82+
| `--azure-subnet-prefix` | `AZURE_SUBNET_PREFIX` | `192.168.0.0/16` |
83+
| `--azure-availability-set` | `AZURE_AVAILABILITY_SET` | `docker-machine` |
84+
| `--azure-open-port` | - | - |
85+
| `--azure-private-ip-address` | - | - |
86+
| `--azure-use-private-ip` | - | - |
87+
| `--azure-no-public-ip` | - | - |
88+
| `--azure-docker-port` | `AZURE_DOCKER_PORT` | `2376` |
89+
90+
## Notes
91+
92+
Azure runs fully on the new [Azure Resource Manager (ARM)][arm] stack. Each
93+
machine created comes with a few more Azure resources associated with it:
94+
95+
* A [Virtual Network][vnet] and a subnet under it is created to place your
96+
machines into. This establishes a local network between your docker machines.
97+
* An [Availability Set][av-set] is created to maximize availability of your
98+
machines.
99+
100+
These are created once when the first machine is created and reused afterwards.
101+
Although they are free resources, driver does a best effort to clean them up
102+
after the last machine using these resources is removed.
103+
104+
Each machine is created with a public dynamic IP address for external
105+
connectivity. All its ports (except Docker and SSH) are closed by default. You
106+
can use `--azure-open-port` argument to specify multiple port numbers to be
107+
accessible from Internet.
108+
109+
Once the machine is created, you can modify [Network Security Group][nsg]
110+
rules and open ports of the machine from the [Azure Portal][portal].
111+
112+
[arm]: https://azure.microsoft.com/en-us/documentation/articles/resource-group-overview/
113+
[nsg]: https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-nsg/
114+
[portal]: https://portal.azure.com/

0 commit comments

Comments
 (0)
X Tutup