Docker Community Forums

Share and learn in the Docker community.

Provision Docker for Azure on an existing Virtual network

docker

(Rajinder Singh) #1

Expected behavior

I was trying to provision docker swarm 1.13 on Azure platform using Docker for Azure template.
I was using Azure portal.
I noticed that even though there were options to select resource group, manager nodes, worker nodes, sizes, pruning on/off etc there was no place to specify an existing virtual network. I exported the template and found that it does create a new virtual network.

I was wondering if it is possible to use Docker for Azure on an existing Virtual network.
I am fine with customizing the ARM template but I don’t want to spend a lot of time on this if there are known issues with running the swarm cluster on an existing virtual network.

Actual behavior

No place to specify existing virtual network and subnets


(Deep Debroy) #2

@rajindersingh … there shouldn’t be an issue that I can think of with deploying on a pre-existing VirtualNetwork by editing the template. You should also be able to change the address range of the subnet hosting the swarmnodes to whatever address range you like distinct from the pre-set one in the template - no hard dependencies there.

I was curious about some specifics regarding your use case: Are you planning to (1) deploy the Docker4Azure template on an existing resource group with a virtual network already present or (2) deploy it in a new resource group but refer to a VNET deployed in a different resource group?


(Rajinder Singh) #3

We have 2 type of virtual networks.

  1. Virtual networks that are associated with express route. Here virtual networks are owned by networking team. Our networking team keeps virtual networks in their resource groups.
  2. We have virtual networks that are not associated with express route. In these cases we do have the ability to have both virtual network and swarm cluster in the same resource group.

We always have existing resource groups.
Is the best way to get the template is to export it from the portal or you share the ARM template directly as well. I did sign up for Docker for Azure.


(Deep Debroy) #4

@rajindersingh I see. You can use the template published at: https://download.docker.com/azure/stable/Docker.tmpl

Please note that when updating pre-existing resource groups with the Docker 4 Azure template, the Service Principal credentials need to be that of a SP that already has access to the existing resource group.


(Markvr) #5

Fr what it’s worth I had the same requirements, and modified the template to add params so I could specify an existing VNET. It seems to be working ok…


(Bmmathe) #6

Could you please share how you specified an existing virtual network in a different resource group?
When I specified my existing vnet name a new one was created in my new resource group with the same name.


(Stationcasinosddc) #7

Where you able to find the changes necessary to accomplish this? I had the same results as it creates a new VNet and not using the existing VNet, which is what I want too.

Any help would be greatly appreciated.


(Bmmathe) #8

customTemplate.txt (26.8 KB)
Take a look at the attached template. Basically just launch the Docker for Azure template from the Docker site then edit the template and use this one. Please review it to make sure it meets your needs. It will add all VMs to your private virtual network and expose both load balancers only on your private network. You have to specify the exact subnet you want to attach the network devices to and you must provide a static IP for the load balancers.

This template specifies the edge channel so if you want the stable channel change the “imageOffer” to “docker-ce” instead of “docker-ce-edge”.