Search code examples
azure-service-fabricgrafana

How to pass command line arguments to docker Grafana container in Service Fabric


I'm trying to run grafana as a container inside my service fabric cluster. The container is healthy if I deploy without commmand line arguments, but when I try to pass command line arguments as shown below in the service manifest it fails.

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="Grafana.Pkg"
                 Version="1.0.0"
                 xmlns="http://schemas.microsoft.com/2011/01/fabric"
                 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <ServiceTypes>
        <StatelessServiceType ServiceTypeName="Grafana.Type" UseImplicitHost="true" />
    </ServiceTypes>

    <!-- Code package is your service executable. -->
    <CodePackage Name="Code" Version="1.0.0">
        <EntryPoint>
            <ContainerHost>
                <ImageName>myregistry.azurecr.io/grafana:6.3.2</ImageName>
        <Commands>-e "GF_SERVER_ROOT_URL=https://serverurl.com/grafana"</Commands>
            </ContainerHost>
        </EntryPoint>
    </CodePackage>

    <ConfigPackage Name="Config" Version="1.0.0" />

    <Resources>
        <Endpoints>
            <Endpoint Name="Grafana.TypeEndpoint" UriScheme="http" Protocol="http" Port="3000" />
        </Endpoints>
    </Resources>
</ServiceManifest>

The actual docker command for running grafana is shown below enter image description here

specifically I need to pass

-e "GF_SERVER_ROOT_URL=http://grafana.server.name"

and

-e "GF_SECURITY_ADMIN_PASSWORD=secret"

What is the recommended way to pass command line arguments in the ServiceFabric manifest? Also is there a way to escape the double quotes that need to be passed in?


Solution

  • The -e arguments for the docker CLI, are environment variables to be set in the container. You can specify them in the manifest.

    <CodePackage Name="Code" Version="1.0.0">
      ...
      <EnvironmentVariables>
        <EnvironmentVariable Name="GF_SERVER_ROOT_URL" Value="https://serverurl.com/grafana"/>    
      </EnvironmentVariables>
    </CodePackage>