docker-compose中的String Interpolate环境变量

问题描述

我有以下docker-compose.yml文件

locat.string="3444 South texas"
AttributeError: 'nonetype' object has no attribute 'string'

秘密“ StripeSecretKey”指向文本文件,其秘密密钥为:

enter image description here

我正在尝试将我的秘密密钥值插入到stripe-cli容器的命令集合中。但是我无法使用上述语法来做到这一点。

在执行上述docker-compose文件时,我收到以下警告:

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

我会很感激。

解决方法

尝试这样

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

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.