> ## Documentation Index
> Fetch the complete documentation index at: https://docs.use.observer/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy on Coolify, Dokploy or Portainer

> Run the agent as a Docker Compose service or stack on your own self-hosted platform.

The Observer Agent runs on your own platform as a small always-on
container. It makes outbound HTTPS calls to Observer and listens on no
public port. Your platform's pricing applies.

## Before you start

Create the agent in Observer: **Agents**, **Add agent**, then **Cloud
platforms**. Copy the key. Observer shows it once. You paste it when
the platform asks for `AGENT_KEY`.

## The compose file

These platforms run a Docker Compose file. Use this one (also on the
Add agent screen):

```yaml title="docker-compose.yml" theme={null}
services:
  observer-agent:
    image: ghcr.io/useobserver/agent:1
    restart: unless-stopped
    environment:
      AGENT_KEY: ${AGENT_KEY:?}
      CLOUD_SERVER_URL: "https://use.observer"
      BUFFER_PATH: "/data/observer-agent-buffer.db"
    volumes:
      - observer-agent-buffer:/data

volumes:
  observer-agent-buffer:
```

The key stays out of the file: `${AGENT_KEY:?}` reads it from the
platform's environment variables and stops the deploy when it is
missing. The volume keeps the [local queue](https://docs.use.observer/agent/concepts/local-queue.md)
when the container is recreated.

## Deploy

> [tab] Coolify
>
> 1. In a project, **New resource**, **Docker Compose Empty**.
> 2. Paste the file and save.
> 3. Under **Environment variables**, set `AGENT_KEY` to your agent key.
> 4. **Deploy**. Do not add a domain: the agent serves nothing.

> [tab] Dokploy
>
> 1. In a project, **Create service**, **Compose**.
> 2. Paste the file under **General**, **Raw**.
> 3. Under **Environment**, add `AGENT_KEY=<your agent key>`.
> 4. **Deploy**. Do not add a domain: the agent serves nothing.

> [tab] Portainer
>
> 1. **Stacks**, **Add stack**, **Web editor**.
> 2. Paste the file.
> 3. Under **Environment variables**, add `AGENT_KEY` with your agent
>    key.
> 4. **Deploy the stack**.

To change the key, for example after a
[key rotation](https://docs.use.observer/agent/guides/rotate-agent-key.md), edit `AGENT_KEY` in the
same place and redeploy. Add other
[environment variables](https://docs.use.observer/agent/reference/environment-variables.md), such
as `PROMETHEUS_SERVER_URL`, under `environment` in the file.

## Check that it connected

The Add agent screen shows **Connected** within a minute of the agent
starting, and the Agents page marks the agent as **running**. If it
does not, open the container's logs in the platform. The agent logs
every failed call to Observer with the reason. The most common cause
is a wrong or replaced `AGENT_KEY`.

## Upgrades

The file runs `ghcr.io/useobserver/agent:1`, which moves to each new
1.x release. Redeploy with a fresh pull of the image to pick up a new
release. In Portainer, update the stack with **Re-pull image and
redeploy** turned on.

## Remove

Delete the service or stack, then its `observer-agent-buffer` volume.
Delete the agent in Observer (**Agents**) too if you no longer need
it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.