brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: pass variables to a portainer stack webhook in the URL and read them in compose

Portainer
~/tips/tip-portainer-stack-webhook-env-variables

image: repository/image:${SERVICE_TAG:-stable}

Passes values to a stack through the webhook URL so one stack file serves several environments.

One webhook can deploy different versions of a stack if the URL carries a variable.

# compose file
image: repository/image:${SERVICE_TAG:-stable}

# trigger
curl -X POST "https://portainer.example.com:9443/api/stacks/webhooks/ID?SERVICE_TAG=development"

A query parameter such as SERVICE_TAG=development on the webhook URL is passed to the stack as an environment variable, and compose can read it with ${SERVICE_TAG:-stable}. The part after :- is the fallback when the caller sends nothing.

This works with the stack webhook feature of Portainer Business Edition. Replace ID with the UUID from the stack editor, and keep the URL private, because anyone who has it can redeploy the stack.

Further reading: Portainer docs: Stack webhooks

More Portainer tips Choose Polling in a Portainer GitOps update when your Git host can't reach Portainer Put Portainer environments in groups and give users access to a whole group Portainer's Edge Agent checks in every 5 seconds, and you can change that docker run -d -p 9001:9001 --name portainer_agent --restart=always \ Deploy the container → Replace All Portainer tips (28) All topics

Link