# Volumes

Source: https://openpanel.sh/docs/volumes

Disk that keeps a folder of a service across deploys, on the one server the service runs on.

A volume keeps one folder of a service's container on disk, so what the service writes there survives deploys, restarts and rollbacks: a database's files, uploads, a cache. It is a Docker volume on your server, named `op-vol-<volume id>`, mounted at the path you choose.

In the console, a service's volumes are on its **Settings** tab, in the **Volumes** card. The [CLI](/docs/cli), the [API](/docs/api) and [MCP](/docs/ai) do the same.

A volume's data lives on one server, so **a service with a volume always runs as one instance**, without replicas or the load balancer. See [The single-instance rule](/docs/volumes/single-instance).

## Add a volume [#add-a-volume]

The service must run one replica with the load balancer off. Adding a volume needs deploy access to the project.

<Tabs items={["Console","CLI","API"]}>
<Tab value="Console">
Open the project, click the service on the canvas, and go to its **Settings** tab. In the **Volumes** card, give the **Mount path** and, if you want a limit, the **Size (GB)**, then click **Add volume**. It is mounted at the next deploy. In **New service**, the **Volumes** section does the same.
</Tab>

<Tab value="CLI">
```sh
openpanel volumes add /data --size 10 --service db --project shop
```

At creation, `openpanel services create` takes `--volume /data:10`, which you can repeat.
</Tab>

<Tab value="API">
```sh
curl -X POST https://openpanel.sh/api/v1/services/$SERVICE_ID/volumes \
  -H "Authorization: Bearer $OPENPANEL_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"mountPath": "/data", "sizeGb": 10}'
```

At creation, `POST /projects/{projectId}/services` takes `"volumes": [{"mountPath": "/data", "sizeGb": 10}]`.
</Tab>
</Tabs>

The volume is created at the service's next deploy, empty.

| Setting | Rule |
|---|---|
| Path | An absolute path in the container, such as `/data` or `/var/lib/postgresql/data`: letters, digits and `_ . - /`, no `..`. One volume per path. |
| Size | Optional, 1 to 100,000 GB. It is recorded, but not enforced: Docker's volumes have no quota, so a volume can fill the server's free disk. |
| How many | Up to 10 per service. |

## Where its data lives [#where-its-data-lives]

At the first deploy after you add it, a volume is pinned to the server the service lands on. From then on the service runs on that server only, whatever other servers it lists:

- the volume's server cannot be taken out of the service's servers;
- if that server is disconnected, the service cannot be deployed until it is back or the volume is removed;
- moving a volume to another server is not offered yet.

At each deploy, the old container stops before the new one starts, so two containers never write to one volume. The service is down for that moment.

## Remove a volume [#remove-a-volume]

Removing a volume needs admin on the project. `openpanel services get` shows each volume's id in brackets.

<Tabs items={["CLI","API"]}>
<Tab value="CLI">
```sh
openpanel volumes remove $VOLUME_ID
```

The CLI asks you to confirm. Add `--yes` where nobody is at the terminal.
</Tab>

<Tab value="API">
```sh
curl -X DELETE https://openpanel.sh/api/v1/volumes/$VOLUME_ID \
  -H "Authorization: Bearer $OPENPANEL_TOKEN"
```
</Tab>
</Tabs>

The running deployment keeps the volume mounted; the next deploy leaves it out.

<Callout type="warn" title="The data stays on the server">
OpenPanel does not delete a volume's data from your server, when you remove the volume, nor when you delete its service or project. The Docker volume `op-vol-<volume id>` stays on the server with its data. To free the space, remove it on the server yourself with `docker volume rm op-vol-<volume id>`. Adding a volume at the same path again makes a new, empty one.
</Callout>

## Back up [#back-up]

Backing up, restoring and moving volumes are not offered yet. See [Back up and restore a volume](/docs/volumes/backups).

<Cards>
<Card href="/docs/volumes/single-instance" title="The single-instance rule" description="Why a service with a volume runs one replica." />

<Card href="/docs/projects/settings" title="Service settings" description="Every setting a service has." />
</Cards>