Skip to content

Commit 1b1764f

Browse files
committed
Doc updated with docker-machine
1 parent 58005c7 commit 1b1764f

4 files changed

Lines changed: 135 additions & 65 deletions

File tree

deploy/az/vms/docker-machine.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Create a VM using docker-machine
2+
3+
Ensure you are logged in the desired subscription Refer to [this article](https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli) for more details.
4+
5+
1. Use `az account show` to find your subscription id.
6+
2. Use `docker-machine create --driver azure --azure-subscription-id <subs_id> --azure-resource-group <resource_group> --azure-ssh-user <login_name> <machine_name>`
7+
8+
After use `docker-machine create` you'll need to authenticate in Azure (even thought if you are logged using `az`, because this is not an Azure CLI 2.0 command). This command will fully create the VM with all the needed settings to run Docker.
9+
10+
**Note** Refer to this article with all the [parameters that docker-machine accepts when creating Azure VMs](https://docs.docker.com/machine/drivers/azure/#options) for finding more parameters.
11+
12+
## Connecting your local environment with docker host running on the VM
13+
14+
Using docker-machine you control the remote VM from your local development environment (you don't need to use ssh to login to remote VM).
15+
16+
Connecting your local environment to a remote host is using by setting some environment variables, but the easiest way is to use again the docker-machine command. Just type `docker-machine env machine_name` (where machine_name is the name you gave when you created the VM). That command **do not change anything**, so do'nt do really nothing, but **outputs the environment variables you have to set**. This is the output of the command (running on a windows workstation):
17+
18+
```
19+
SET DOCKER_TLS_VERIFY=1
20+
SET DOCKER_HOST=tcp://104.42.236.237:2376
21+
SET DOCKER_CERT_PATH=C:\Users\etoma\.docker\machine\machines\ufohost
22+
SET DOCKER_MACHINE_NAME=ufohost
23+
SET COMPOSE_CONVERT_WINDOWS_PATHS=true
24+
REM Run this command to configure your shell:
25+
REM @FOR /f "tokens=*" %i IN ('docker-machine env ufohost') DO @%i
26+
```
27+
28+
You have to set all these environment variables, or (as the command suggest) just copy and paste the last line in your terminal.
29+
30+
Once you did this, your local development machine is connected to VM running Docker on Azure: all docker and docker-compose commands will run in the VM instead of your local Docker machine!
31+
32+
33+
34+
35+
36+
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+

deploy/az/vms/plain-vm.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Deploy a VM to run the services
2+
3+
Follow these instructions to deploy a Linux-based VM with the Docker Host installed, or a VM with Windows Server 2016 plus
4+
windows containers and Docker Daemon.
5+
6+
**Note**: Use this option, only if you want to provide an environment using images pulled from DockerHub (for example, to create a test environment). If you want to
7+
be able to deploy images built by yourself (but not pushed to DockerHub) follow the [instructions about using docker-machine](./docker-machine.md).
8+
9+
You can use this machine to install the microservices and having a "development" environment (useful to develop and test the client apps).
10+
11+
Please note that this deployment is not a production deployment. In a production-based scenario, you should deploy all containers in ACS.
12+
13+
## Create the VM
14+
15+
Ensure you are logged in the desired subscription (use `az login` and `az account set` if needed. Refer to [this article](https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli) for more details.
16+
17+
Go to `linux-vm` or `win-vm` folder (based on if you want a Linux or Windows VM). Then:
18+
19+
1. Edit the file `linuxvm.parameters.json` or `windowsvm.parameters.json` (based on what VM do you want to create) with your desired values
20+
2. Run the [create-resources script](../readme.md) to deploy the desired template (`linux-vm/linuxvm.json` or `win-vm/windowsvm.json`).
21+
22+
I. e. if you are in Windows and want to deploy a linux based VM, in a new resourcegroup located in westus, go to `deploy\az` folder and type:
23+
24+
```
25+
create-resources.cmd vms\linux-vm\linuxvm newResourceGroup -c westus
26+
```
27+
28+
**Note:** To avoid errors, ARM template used generates unique names for:
29+
30+
1. VM used storage
31+
2. Public DNS
32+
33+
Those public names are based on the parameters set in the parameters file.
34+
35+
### The parameters file (linuxvm.parameters.json or winsowsvm.parameters.json)
36+
37+
Both files are identical and contains the minimum set of parameters needed by the ARM template to deploy the VM. ARM template accepts some other parameters (set with default values). Look the template for more info.
38+
39+
The parameters defined are:
40+
41+
1. `newStorageAccountName`: Name of the storage created for the VM. To ensure uniqueness a unique suffix will be added to this value.
42+
2. `adminUsername`: Admin login
43+
3. `adminPassword`: Admin password
44+
4. `dnsNameForPublicIP`: DNS of the VM. To ensure uniqueness a unique suffix will be added to this value.
45+
5. `VMName`: Name of the VM inside Azure
46+
47+
## Finding the IP and DNS of the VM
48+
49+
To find the IP and FQDN of the VM you can type `az vm list --resource-group <resourcegroup> --output table --show-details` (where resourcegroup is the
50+
name of the resourcegroup where you created the VM). This command will generate output like:
51+
52+
```
53+
Name ResourceGroup PowerState PublicIps Fqdns Location
54+
---------- --------------- ------------ ------------- ------------------------------------------------ ----------
55+
MyDockerVM MyResourceGroup VM running xx.xx.xxx.xxx eshop-srvxxxxxxxxxxxxx.westus.cloudapp.azure.com westus
56+
```
57+
58+
You can use this information to connect your new VM.
59+
60+
## Deploy services in the VM
61+
62+
We are providing public images of the services in DockerHub (https://hub.docker.com/u/eshop/). To use these images, just create a folder in the VM and copy
63+
following files to it (those files are in the root of the repo):
64+
65+
1. `docker-compose.nobuild.yml`
66+
2. `docker-compose.prod.yml`
67+
68+
**Note:** The `docker-compose.nobuild.yml` is just a version of the `docker-compose.yml` without the `build` section. Is neede due [docker-compose bug](https://github.com/docker/compose/issues/2945).
69+
70+
Then log into the VM and run the command `docker-compose -f docker-compose.nobuild.yml -f docker-compose.prod.yml up --no-build -d` to start all the microservices.
71+
72+
73+
74+
75+
76+
77+

deploy/az/vms/readme.md

Lines changed: 6 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,10 @@
1-
# Deploy a VM to run the services
1+
## Create VM with Docker installed
22

3-
Follow these instructions to deploy a Linux-based VM with the Docker Host installed, or a VM with Windows Server 2016 plus
4-
windows containers and Docker Daemon.
5-
6-
You can use this machine to install the microservices and having a "development" environment (useful to develop and test the client apps).
7-
8-
Please note that this deployment is not a production deployment. In a production-based scenario, you should deploy all containers in ACS.
9-
10-
## Create the VM
11-
12-
Ensure you are logged in the desired subscription (use `az login` and `az account set` if needed. Refer to [this article](https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli) for more details.
13-
14-
Go to `linux-vm` or `win-vm` folder (based on if you want a Linux or Windows VM). Then:
15-
16-
1. Edit the file `linuxvm.parameters.json` or `windowsvm.parameters.json` (based on what VM do you want to create) with your desired values
17-
2. Run the [create-resources script](../readme.md) to deploy the desired template (`linux-vm/linuxvm.json` or `win-vm/windowsvm.json`).
18-
19-
I. e. if you are in Windows and want to deploy a linux based VM, in a new resourcegroup located in westus, go to `deploy\az` folder and type:
20-
21-
```
22-
create-resources.cmd vms\linux-vm\linuxvm newResourceGroup -c westus
23-
```
24-
25-
**Note:** To avoid errors, ARM template used generates unique names for:
26-
27-
1. VM used storage
28-
2. Public DNS
29-
30-
Those public names are based on the parameters set in the parameters file.
31-
32-
### The parameters file (linuxvm.parameters.json or winsowsvm.parameters.json)
33-
34-
Both files are identical and contains the minimum set of parameters needed by the ARM template to deploy the VM. ARM template accepts some other parameters (set with default values). Look the template for more info.
35-
36-
The parameters defined are:
37-
38-
1. `newStorageAccountName`: Name of the storage created for the VM. To ensure uniqueness a unique suffix will be added to this value.
39-
2. `adminUsername`: Admin login
40-
3. `adminPassword`: Admin password
41-
4. `dnsNameForPublicIP`: DNS of the VM. To ensure uniqueness a unique suffix will be added to this value.
42-
5. `VMName`: Name of the VM inside Azure
43-
44-
## Finding the IP and DNS of the VM
45-
46-
To find the IP and FQDN of the VM you can type `az vm list --resource-group <resourcegroup> --output table --show-details` (where resourcegroup is the
47-
name of the resourcegroup where you created the VM). This command will generate output like:
48-
49-
```
50-
Name ResourceGroup PowerState PublicIps Fqdns Location
51-
---------- --------------- ------------ ------------- ------------------------------------------------ ----------
52-
MyDockerVM MyResourceGroup VM running xx.xx.xxx.xxx eshop-srvxxxxxxxxxxxxx.westus.cloudapp.azure.com westus
53-
```
54-
55-
You can use this information to connect your new VM.
56-
57-
## Deploy services in the VM
58-
59-
We are providing public images of the services in DockerHub (https://hub.docker.com/u/eshop/). To use these images, just create a folder in the VM and copy
60-
following files to it (those files are in the root of the repo):
61-
62-
1. `docker-compose.yml`
63-
2. `docker-compose.prod.yml`
64-
65-
Then log into the VM and run the command `docker-compose -f docker-compose.yml -f docker-compose.prod.yml up --no-build -d` to start all the microservices.
3+
There are two options for creating VM machines with Docker installed:
664

5+
1. [Deploying a Linux VM to run single-server development environment using docker-machine (**Recommended for development environments**)](./docker-machine.md)
6+
2. [Deploying a Linux VM or Windows Server 2016 to run a single-server development environment using ARM template (**Recommended for creating testing environments**)](./plain-vm.md)
677

8+
If you want to create a VM for deploying images you build locally, then use the first option.
689

10+
If you want to create a VM to run images deployed to DockerHub (to provide some test environment) then use the second option.

deploy/readme.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ Login into your azure subscription by typing `az login` (note that you maybe nee
1010

1111
## Deploying Virtual machines to host the services
1212

13-
1. [Deploying a Linux VM or Windows Server 2016 to run a single-development environment](az/vms/readme.md)
13+
1. [Deploying a Linux VM to run single-server development environment using docker-machine (**Recommended for development environments**)](az/vms/docker-machine.md)
14+
2. [Deploying a Linux VM or Windows Server 2016 to run a single-server development environment using ARM template (**Recommended for creating testing environments**)](az/vms/plain-vm.md)
15+
16+
Using `docker-machine` is the recommended way to create a VM with docker installed. But it is limited to Linux based VMs.
1417

1518
## Deploying Azure resources used by the services
1619

0 commit comments

Comments
 (0)