Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Stripe CLI correctly in docker

I would like to use Stripe CLI in docker. I have to mention that I am new to docker. I have loaded stripe/stripe-cli from dockerHub.

docker run --rm -it stripe/stripe-cli:latest.

docker image ls also shows me that the image is available locally. But docker ps does not show me a stripe CLI container? Is this right or wrong?

When I run docker run -it stripe/stripe-cli login

I have to authenticate with Stripe in the browser. This is the output:

Your pairing code is: xxxx-xxxx-xxx-xxxxx
This pairing code verifies your authentication with Stripe.
To authenticate with Stripe, please go to: https://dashboard.stripe.com/stripecli/confirm_auth?t=5ifDAxXxXxXxXxX
⣾ Waiting for confirmation... > Done! The Stripe CLI is configured for Mike's Test Stripe with account id add1_xxx

Please note: this key will expire after 90 days, at which point you'll need to re-authenticate.

My que I do that successfully but I still can't use stripe-cli afterwards? What am I missing?

like image 344
Maik Lowrey Avatar asked Feb 02 '26 16:02

Maik Lowrey


1 Answers

I think there should be a docker compose solution too here. This is my working setup:

Framework: Django 4

Python: 3.9

version: "3.9"
   
services:
  stripe-cli:
    image: stripe/stripe-cli
    container_name: stripe-cli
    command: "listen --api-key ${STRIPE_API_KEY} --device-name ${STRIPE_DEVICE_NAME} --forward-to web:8000/payment/webhook/"
    env_file:
      - stripe_cli.env
  
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    

Contents of .env file (remember this should stay locally on the machine. Dont commit this file. create it locally)

STRIPE_API_KEY = rk_test_somelongkey***************
STRIPE_DEVICE_NAME = Name

Please note a few things:

In "web:8000", 'web' is service name of the django project

like image 70
Arindam Roychowdhury Avatar answered Feb 05 '26 07:02

Arindam Roychowdhury



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!