简体   繁体   中英

String Interpolate environment variable in docker-compose

I have the following docker-compose.yml file:

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:

在此处输入图像描述

I am trying to string interpolate my secret key value in the command argumant of the stripe-cli container. But I am unable to do so with the above syntax.

I am getting the following warning when executing the above docker-compose file:

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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