Use Docker volume plug-ins and logging drivers in your container

Azure Service Fabric supports specifying Docker volume plug-ins and Docker logging drivers for your container service. You can persist your data in Azure Files when your container is moved or restarted on a different host.

Only volume drivers for Linux containers are currently supported. If you're using Windows containers, you can map a volume to an Azure Files SMB3 share without a volume driver. For this mapping, update your virtual machines (VMs) in your cluster to the latest Windows Server 1709 version.

Install the Docker volume/logging driver

If the Docker volume/logging driver is not installed on the machine, you can install it manually by using the RDP/SSH protocols. You can perform the install with these protocols through a virtual machine scale set start-up script or an SetupEntryPoint script.

An example of the script to install the Docker volume driver for Azure is as follows:

docker plugin install --alias azure --grant-all-permissions docker4x/cloudstor:17.09.0-ce-azure1  \

Specify the plug-in or driver in the manifest

The plug-ins are specified in the application manifest as follows:

?xml version="1.0" encoding="UTF-8"?>
<ApplicationManifest ApplicationTypeName="WinNodeJsApp" ApplicationTypeVersion="1.0" xmlns="" xmlns:xsi="">
    <Description>Calculator Application</Description>
        <Parameter Name="ServiceInstanceCount" DefaultValue="3"></Parameter>
      <Parameter Name="MyCpuShares" DefaultValue="3"></Parameter>
        <ServiceManifestRef ServiceManifestName="NodeServicePackage" ServiceManifestVersion="1.0"/>
       <ContainerHostPolicies CodePackageRef="NodeService.Code" Isolation="hyperv"> 
        <PortBinding ContainerPort="8905" EndpointRef="Endpoint1"/>
        <RepositoryCredentials PasswordEncrypted="false" Password="****" AccountName="test"/>
        <LogConfig Driver="etwlogs" >
          <DriverOption Name="test" Value="vale"/>
        <Volume Source="c:\workspace" Destination="c:\testmountlocation1" IsReadOnly="false"></Volume>
        <Volume Source="d:\myfolder" Destination="c:\testmountlocation2" IsReadOnly="true"> </Volume>
        <Volume Source="myvolume1" Destination="c:\testmountlocation2" Driver="azure" IsReadOnly="true">
           <DriverOption Name="share" Value="models"/>
        <StatelessService ServiceTypeName="StatelessNodeService" InstanceCount="5">

The Source tag for the Volume element refers to the source folder. The source folder can be a folder in the VM that hosts the containers or a persistent remote store. The Destination tag is the location that the Source is mapped to within the running container. Thus, your destination can't be a location that already exists within your container.

When specifying a volume plug-in, Service Fabric automatically creates the volume by using the specified parameters. The Source tag is the name of the volume and the Driver tag specifies the volume driver plug-in. Options can be specified by using the DriverOption tag as follows:

<Volume Source="myvolume1" Destination="c:\testmountlocation4" Driver="azure" IsReadOnly="true">
           <DriverOption Name="share" Value="models"/>

If a Docker log driver is specified, you have to deploy agents (or containers) to handle the logs in the cluster. The DriverOption tag can be used to specify options for the log driver.

Next steps

To deploy containers to a Service Fabric cluster, see Deploy a container on Service Fabric.