> For the complete documentation index, see [llms.txt](https://www.trentbauer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.trentbauer.com/guides/installation-guides/portainer/deploy-your-first-gitops-stack.md).

# Stacks (docker compose)

<table data-view="cards"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td>Time Required</td><td>30 Minutes</td></tr><tr><td>Difficulty</td><td>Low - Moderate</td></tr><tr><td>Required Knowledge</td><td>Portainer, Docker compose</td></tr></tbody></table>

## What is a Stack?

Stacks is how Portainer handles Docker Compose files, which are infrastructure as code documents for spinning up multiple containers, volumes and networks in 1 go.

Most docker container developers now provide example compose files with their projects. Its also possible to Google and find examples online

***

For example, you may have a service that has a separate container for

* *a database*
* *a web app*
* *back end compute*

*The database and back end compute may be on Network 1, while the web app is on Network 2.*

*All 3 containers have access to the same 'config' volume, but the database and webapp have their own unique volumes*

*The database and backend need the same credentials to the 2 systems can talk, but the web app has separate credentials for the gui. These are environmental variables*

***

Instead of manually setting up and inputting environmental variables, networks and volumes for each container this can all be written into the compose and and span up in 1 click. This also makes the set up system agnostic.

## Deploy your Stack

{% tabs %}
{% tab title="GitOps Private" %}
{% hint style="info" %}
In this example, we're going to deploy the Ombi compose file we created in [Create your first compose file](/guides/installation-guides/gitops/create-your-first-gipops-compose-file.md)
{% endhint %}

1. Log into Portainer
   1. If you set up Edge Agents, click on the host you want Ombi to exist on
2. On the left hand menu, select 'Stacks'
3. Click on 'Add stack'
   1. Give your stack a name (eg "ombi")
   2. Build method = Repository
   3. Tick 'Authentication'
      * Username = Github Email
      * Personal Access Token = PAC saved in [Create your GitHub Repo](/guides/installation-guides/gitops/create-your-github-repo.md)
   4. Repository URL = the URL of your repo + .git (eg "<https://github.com/trentnbauer/agg.local.git\\_"\\>\_)
   5. Compose path = docker-compose/ombi.yml
   6. Tick 'Automatic updates'\
      You should see a page similar to this
   7. Scroll down to the 'environment variables' section and add the following variables

      * TZ
      * BASE\_URL
      * PORT\_HTTP

      <figure><img src="/files/zs4wtELZlivHinX5Hd63" alt=""><figcaption></figcaption></figure>
   8. Provide your TZ per the ['tz identifier' here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
   9. Provide a base url, if you are using one (not required)
   10. Provide the port that Ombi will use
   11. Click on 'Deploy the stack'
       {% endtab %}

{% tab title="GitOps Public" %}
{% hint style="info" %}
In this example, we're going to deploy the Ombi compose file we created in [Create your first compose file](/guides/installation-guides/gitops/create-your-first-gipops-compose-file.md)
{% endhint %}

1. Log into Portainer
   1. If you set up Edge Agents, click on the host you want Ombi to exist on
2. On the left hand menu, select 'Stacks'
3. Click on 'Add stack'
   1. Give your stack a name (eg "ombi")
   2. Build method = Repository
   3. Repository URL = the URL of your repo + .git (eg "<https://github.com/trentnbauer/agg.local.git\\_"\\>\_)
   4. Compose path = docker-compose/ombi.yml
   5. Tick 'Automatic updates'\
      You should see a page similar to this
   6. Scroll down to the 'environment variables' section and add the following variables

      * TZ
      * BASE\_URL
      * PORT\_HTTP

      <figure><img src="/files/zs4wtELZlivHinX5Hd63" alt=""><figcaption></figcaption></figure>
   7. Provide your TZ per the ['tz identifier' here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
   8. Provide a base url, if you are using one (not required)
   9. Provide the port that Ombi will use
   10. Click on 'Deploy the stack'
       {% endtab %}

{% tab title="Copy paste / write in Portainer" %}
{% hint style="info" %}
While this is easier than using GitOps, its no where near as powerful and will require manual intervention to update containers.

I do this often when I am building compose files, as its easier to work with the native editor as aposed to GitHub
{% endhint %}

1. Log into Portainer
   1. If you set up Edge Agents, click on the host you want Ombi to exist on
2. On the left hand menu, select 'Stacks'
3. Click on 'Add stack'
   1. Give your stack a name (eg "ombi")
   2. Build method = Web editor
4. Paste your compose file into the web editor and make any adjustments required
   {% endtab %}
   {% endtabs %}

If you have any issues, refer to the Notifications tab at the top of the page;

<figure><img src="/files/hH8ayQ0PaCzdOevraSeg" alt=""><figcaption></figcaption></figure>

Most Portainer errors can be resolved with a simple Google search but I also have my own [troubleshooting list here](https://github.com/trentnbauer/agg-docs/blob/main/guides/portainer-and-gitops/broken-reference/README.md)

### Updating Stacks

If you have used GitOps, Portainer will check in with GitHub and download the updated compose file and update the container image.

You can tell Portainer to manually pull by;

1. Browse to the stack
2. Click on 'Pull and redeploy'

If you have not used GitOps you will need to edit the stack yourself as needed


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://www.trentbauer.com/guides/installation-guides/portainer/deploy-your-first-gitops-stack.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
