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: Additional paths in a Portainer Git stack merge extra compose files

Git
~/tips/tip-git-portainer-additional-paths

Compose path: docker-compose.yml

Loads a second compose file from the same repository on top of the main one.

A lot of projects split their setup into a base compose file and an override per environment. A Portainer stack from Git can read both, through a field called Additional paths.

When you create a stack with the Git repository build method, you fill in the Compose path, the path of the main compose file from the root of the repository. Below it, Additional paths lets you add more YAML files. Portainer’s docs say they’re handled the way docker compose handles several -f options, with the same merge rules.

Compose path:     docker-compose.yml
Additional paths: compose.prod.yml

That matches what I’d run on a server by hand:

docker compose -f docker-compose.yml -f compose.prod.yml up -d

So the production file only needs the differences: other ports, extra volumes, a different image tag. I like keeping it like that, because the base file then works for local testing without any changes.

The order matters. Later files override earlier ones, so a value in compose.prod.yml wins over the same value in the main file, while lists like ports are combined rather than replaced. Before this goes into Portainer, check the combined result locally with docker compose -f docker-compose.yml -f compose.prod.yml config. If that output looks wrong, the stack will look wrong too.

Further reading: Portainer docs: add a new stack, Docker docs: merge Compose files

More Git tips git show-branch main feature git log --stat -5 git merge --no-ff feature -m "Merge feature" git merge --squash feature git merge --abort All Git tips (144) All topics

Link