다음을 통해 공유


Docker Blog Series Part 5 – Understanding new container management features in Service Fabric

Service Fabric is a distributed systems platform that makes it easy to package, deploy, and manage scalable and reliable microservices and containers. Service Fabric also addresses the significant challenges in developing and managing cloud native applications. It is also an orchestrator of services across a cluster of machines and it is continuing to invest heavily in container orchestration and management. In this blog post, we will check out some of newer features as they relate to container orchestration - Volume Mounting and Docker Compose support.

Containers are encapsulated, individually deployable components that run as isolated instances on the same kernel to take advantage of virtualization that an operating system provides. Thus, each application and its runtime, dependencies, and system libraries run inside a container with full, private access to the container's own isolated view of operating system constructs.

Volumes

In the world of containers, volumes are a great way to persist data created and used by the docker containers. Let’s take a look at how to use volumes in Service Fabric.

Step 1 – Create a new Service Fabric Application using VS2017.

image

Step 2 –Use  the Container template and provide the docker container image previously built. You can check out my earlier blog posts to learn about creating docker images/applications.

image

Once the project is created, Visual Studio will create the necessary manifest files ready for publishing. Before we publish let us configure the volumes in the ApplicationManifest.

Step 3 – Open the ApplicationManifest.xml and Add the Volume Policy as shown below under Policies inside ServiceManifestImport.

SNAGHTML88506c

 

Step 4 - Now you are ready to publish the application and use the volumes.

 

image

You can also use volume drivers like Azure File Share with Service Fabric Volumes. You can read more on it here - https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-containers-volume-logging-drivers

 

Docker Compose Support

Docker uses the docker-compose.yml file for defining multi-container applications. To make it easy for customers familiar with Docker to orchestrate existing container applications on Azure Service Fabric, natively in the platform, Service Fabric can accept version 3 and later of docker-compose.yml files.

As a pre-requisite, we will use the container image we used earlier to create a docker-compose.yml file.

Step 1 – Create a docker-compose.yml file as shown below.

SNAGHTMLc0cb49

The above compose file when deployed is going to create a Service Fabric service called ‘customer’ using the image provided.

Step 2 – Connect to Service Fabric cluster in Azure using the following powershell script.

Connect-ServiceFabricCluster -ConnectionEndpoint '_YOURSFCLUSTER_:19000'

Step 3 – Execute the Service Fabric Docker Compose deployment command

New-ServiceFabricComposeDeployment -DeploymentName app -Compose 'docker-compose-servicefabric.yml' -RegistryUserName 'xyz' -RegistryPassword 'xyz'

Once the command is executed Service Fabric application will be created in Azure Service Fabric using the Docker-Compose feature. As you saw in this blog post, we can leverage newer features with Service Fabric for Container Orchestration. Happy Containerizing!!!

References https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-overview https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-containers-overview https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-docker-compose

Comments

  • Anonymous
    December 24, 2017
    thanks a lot, this article save a lot of my time
    • Anonymous
      December 30, 2017
      Glad, you found it useful.