简体   繁体   English

docker-compose 中的字符串插值环境变量

[英]String Interpolate environment variable in docker-compose

I have the following docker-compose.yml file:我有以下 docker-compose.yml 文件:

version: '3.6'

services:
    stripe-cli:
        image: stripe/stripe-cli:latest
        container_name: stripe-cli
        secrets:
            - StripeSecretKey
        environment:
            StripeSecretKey: /run/secrets/StripeSecretKey
        command: --api-key ${StripeSecretKey} listen --forward-to http://localhost:5000/api/payment/webhook
            
secrets:
    StripeSecretKey:
        file: ./secrets/StripeSecretKey.txt

The secret 'StripeSecretKey' points to a text file which has the secret key being:秘密“StripeSecretKey”指向一个文本文件,其密钥为:

在此处输入图像描述

I am trying to string interpolate my secret key value in the command argumant of the stripe-cli container.我正在尝试在 stripe-cli 容器的命令参数中对我的密钥值进行字符串插值。 But I am unable to do so with the above syntax.但我无法使用上述语法这样做。

I am getting the following warning when executing the above docker-compose file:执行上述 docker-compose 文件时,我收到以下警告:

WARNING: The StripeSecretKey variable is not set. Defaulting to a blank string.

I would appreciate the help.我将不胜感激。

Try like this像这样试试

        environment:
            STRIPE_API_KEY: /run/secrets/StripeSecretKey
        command: listen --forward-to http://localhost:5000

https://stripe.com/docs/cli/api_keys You can set two environment variables, which take precedence over all other values: https://stripe.com/docs/cli/api_keys您可以设置两个环境变量,它们优先于所有其他值:

STRIPE_API_KEY: the API key to use for the CLI.
STRIPE_DEVICE_NAME: the device name for the CLI, visible in the Dashboard.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM