如何在Service Fabric中将命令行参数传递给docker Grafana容器 [英] How to pass command line arguments to docker Grafana container in Service Fabric

查看:50
本文介绍了如何在Service Fabric中将命令行参数传递给docker Grafana容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将grafana作为我的服务结构集群中的容器运行.如果我在部署时不使用命令行参数,则该容器是健康的,但是当我尝试传递服务清单中如下所示的命令行参数时,它将失败.

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>

运行grafana的实际docker命令如下所示

The actual docker command for running grafana is shown below

我需要通过

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

-e "GF_SECURITY_ADMIN_PASSWORD=secret"

在ServiceFabric清单中传递命令行参数的推荐方法是什么?还有一种方法可以避免需要传递的双引号吗?

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?

推荐答案

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>

这篇关于如何在Service Fabric中将命令行参数传递给docker Grafana容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆