Deploy a Docker Compose Stack from Git in Portainer
Deploy and update multi-container Docker applications from Git through Portainer Stacks without running commands on the target host.
14 Dec 2025, 02:24 UTC

Deploy a Docker Compose stack from Git without touching the target host
Teams often manage multi-container applications by signing into a Docker host and running docker compose up manually. That approach creates configuration drift, makes updates hard to audit, and requires SSH access to every endpoint. Portainer Stacks lets you store docker-compose.yml in a Git repository and deploy or update the stack from the Portainer UI. The target host does not need Git installed, and you do not need to run deployment commands on it.
Takeaway: if Portainer can reach the Git repository and the target Docker endpoint, you can deploy and update a multi-container application from a single commit.
Prerequisites
- Portainer CE or Business installed and reachable.
- One Docker endpoint registered in Portainer, either the local environment or a remote host managed by a Portainer agent.
- A Git repository reachable from the Portainer server or from the agent, depending on deployment mode, containing
docker-compose.yml. - A Portainer user or team with stack deployment rights on the target endpoint.
- Knowledge of your installed edition. Portainer CE and Business differ in private registry authentication, team-based stack access controls, and webhook triggers.
Example application manifest
Use a compose file similar to this example. Replace image names and ports with values for your application.
services:
web:
image: nginx:1.25
ports:
- "8080:80"
app:
image: myregistry.example.com/example/app:1.0.0
environment:
- APP_ENV=production
Commit this file to your repository at a stable path, such as docker-compose.yml in the repository root.
Optional: validate the file on your administration workstation before pointing Portainer at it:
git clone https://git.example.com/team/example-app.git
cd example-app
docker compose config
Run these commands on a workstation with Git and Docker Compose installed. You need read access to the repository. docker compose config prints the resolved configuration and exits without changing any running containers.
Add the stack in Portainer
- Open Portainer and select Stacks in the left navigation.
- Select Add stack.
- Choose Git as the deployment method.
- Enter the repository URL, branch, and the path to the compose file, for example
docker-compose.yml. - Enter any environment variables required by the compose file. Avoid pasting database passwords or API keys directly into the compose file or the Portainer environment variable field; anyone with stack read access can see them. Use Portainer secrets where available, or bind environment variables from a protected store.
- Select the target Docker endpoint.
- Select Deploy the stack.
Portainer pulls the repository, reads the compose file, and creates the containers on the selected endpoint. The initial deployment can take several seconds to minutes depending on image size and network speed.
Validate the deployment
- On the Stacks page, confirm the stack lists State as Active and is assigned to the intended endpoint.
- Open the endpoint, select Containers, and confirm the services from the compose file are running.
- Open a browser or run
curl -I http://<host>:8080against the published port. Expect a successful HTTP response from the container. - After pushing a change to Git, open the stack in Portainer, select Update, and confirm the new image tag or configuration appears after the update completes.
Run the curl check from a machine that can reach the endpoint's published port. It is read-only and safe.
Update and rollback
Because deploying a stack creates or modifies containers, it changes system state. Keep these recovery options available:
- Redeploy an earlier revision: open the stack in Portainer, check the revision history, and redeploy a previous version if Portainer retains it for that stack.
- Revert in Git: push a revert commit to the compose file, then trigger a stack update from Portainer.
- Remove and recreate: delete the stack and redeploy from the last known good manifest. Deleting a stack removes the containers it created. Back up any application data stored in volumes before deletion unless the volumes are managed externally.
Limitations and practical checks
- Git authentication failures or network timeouts between Portainer and the Git host can cause silent-looking deployment failures. Inspect stack logs and endpoint agent connectivity if the stack does not become Active.
- Portainer must reach the Git host. If you use a remote agent endpoint, confirm whether the server or the agent performs the Git clone in your Portainer version and deployment mode.
- Webhook-based redeployments and fine-grained team access to stacks may require Portainer Business. Confirm your edition before designing an automated pipeline around those features.
Practical check: after deployment, open the stack's logs in Portainer. Successful pulls and container creation appear there; authentication or network errors are usually recorded before the stack state changes to Active.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.