You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
2.2 KiB

  1. # Create a VM using docker-machine
  2. 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.
  3. 1. Use `az account show` to find your subscription id.
  4. 2. Use `docker-machine create --driver azure --azure-subscription-id <subs_id> --azure-resource-group <resource_group> --azure-ssh-user <login_name> <machine_name>`
  5. 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.
  6. **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.
  7. ## Connecting your local environment with docker host running on the VM
  8. 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).
  9. 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):
  10. ```
  11. SET DOCKER_TLS_VERIFY=1
  12. SET DOCKER_HOST=tcp://104.42.236.237:2376
  13. SET DOCKER_CERT_PATH=C:\Users\etoma\.docker\machine\machines\ufohost
  14. SET DOCKER_MACHINE_NAME=ufohost
  15. SET COMPOSE_CONVERT_WINDOWS_PATHS=true
  16. REM Run this command to configure your shell:
  17. REM @FOR /f "tokens=*" %i IN ('docker-machine env ufohost') DO @%i
  18. ```
  19. You have to set all these environment variables, or (as the command suggest) just copy and paste the last line in your terminal.
  20. 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!