Last week on the Build 2017 conference in Seattle Microsoft showed how they have added support for Docker compose to Azure Service Fabric. They demonstrated this on stage during a breakout session on day 2.

When you want to try this yourself the getting started is missing a lot of information. In this post, I will try to explain what you have to do to get this running.

First you have to make sure you deploy a Service Fabric cluster in Azure which meets the following prerequisites:

  • Deployed on Windows Server 2016 Datacenter with Containers
  • Has fabric version 255.255.5713.255 or newer
  • Has DnsService deployed and enabled
  • Has port 80 opened on the loadbalancer

After these requirements are met you can deploy a Docker composed application to this cluster using the Azure CLI.

Creating a Cluster

Let’s start with creating a cluster using the portal. Make sure that you select the options using the image below to select the needed options.
Step 1 Create Service Fabric Cluster
In the next step select the options as below
Step 2 Create Service Fabric Cluster
Now in the last step instead of clicking Create to actually create the cluster use the download template and parameters button. Save this zip file and unpack it to modify the template.json file. Locate the “type”: “Microsoft.ServiceFabric/clusters” part in this json file and change the following:

  • Change the apiVersion to 2017-07-01-preview
  • Add the Service Fabric DnsNamingService after the “fabricSettings”: [] inside the addonFeatures node.

The fabric part should look like this afterwards:

1
2
3
4
"fabricSettings": [],
"addonFeatures": [
"DnsService"
],

Now the deploy the ARM template using your preferred method. For example, using the Deploy.ps1 powershell script included in the zip file.

Checking the Cluster

After deployment go to the Service Fabric explorer of the newly created cluster and check that the DnsService is running. The system section of the cluster should look like DnsService inside Service Fabric

Deploy a containerized application

Now we are ready to the deploy a Docker application using Azure CLI and Docker compose. Make sure you have the Azure CLI 2.0 installed and updated. I am using version 2.0.6. You can find it here Azure CLI.

Next, create a Docker compose application using the following contents.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
version: '3'

services:

legacyenterprisedataapp:
image: mfussell/legacyenterprisedataapp:v3
ports:
- "8080:8080"

legacyenterprisewebapp:
image: mfussell/legacyenterprisewebapp:v3
ports:
- "80:80"

networks:
default:
external:
name: nat

Connect to the cluster using az sf cluster select –endpoint http://clustername.westeurope.cloudapp.azure.com:19080. Check the connection using az sf cluster health

Now deploy your Docker composed application to Service Fabric using az sf compose create –application-id fabric:/Build2017App –compose-file docker-compose.yml

Checking the Service Fabric explorer should reveal that one application is deployed with the name Build2017App. Browsing to http://clustername.westeurope.cloudapp.azure.com now shows the Legacy Enterprise Webapp showed on Build 2017 running on Service Fabric.

Docker Application running on Service Fabric