Docker Machine with an existing Azure VNET

by Carlos Mendible on 26 Feb 2017 » Azure

Last week I had to provision a Docker host and I tried out the docker-machine command. The resulting host would have to use an existing Azure subnet from another resource group and I also needed to be able to reach the machine using it’s private IP.

After reading the docs and playing for some minutes I came up with the correct command to use Docker Machine with an existing Azure VNET:

    docker-machine create --driver azure --azure-subscription-id [subscriptionid]  `
       --azure-resource-group [Resource group] --azure-location [Azure location]  `
       --azure-vnet [Resource group]:[Azure VNET] --azure-subnet [Azure Subnet Name]  `
       --azure-subnet-prefix [Azure subnet prefix (CIDR notation)] --azure-use-private-ip [machine name]

Hope it helps!