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

# Docker containers

> Back up databases running inside Docker containers.

Capsule supports databases running inside Docker containers. Instead of connecting over a network port, Capsule uses `docker exec` to run the dump command directly inside the container — no exposed port required.

***

## How it works

When you add a connection and specify a container name, Capsule:

1. Runs `docker exec <container> <dump-command>` inside the container
2. Streams the dump output to the host
3. Encrypts and uploads the result — same as any other backup

The database tools (`pg_dump`, `mysqldump`, `mongodump`) must be present **inside the container**. Most official database images include them by default.

***

## Adding a Docker connection

In the Capsule TUI:

1. Choose your database type (Postgres, MySQL, MongoDB)
2. Fill in the connection details (host, port, credentials) as normal
3. In the **Docker container** field, enter the container name or ID

```
Container name: my_postgres_container
```

Leave the container field blank for non-Docker connections.

***

## Find your container name

```bash theme={null}
docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}"
```

***

## No exposed port needed

Because Capsule execs inside the container, the database port does not need to be published to the host (`-p 5432:5432` is not required). This is safer — your database stays off the network.

***

## Docker Compose

If you use Docker Compose, the container name is typically `<project>_<service>_1` or `<project>-<service>-1` depending on your Compose version.

```bash theme={null}
# Find the exact name
docker compose ps
```

***

## Requirements

* `docker` must be available in the PATH of the user running Capsule
* The Capsule user must have permission to run `docker exec` (typically by being in the `docker` group)

```bash theme={null}
# Add the capsule user to the docker group
sudo usermod -aG docker $USER
```

Run `capsule doctor` to verify Docker access.

***

## Troubleshooting

**`docker: permission denied`**

Add the Capsule user to the `docker` group and log out/back in:

```bash theme={null}
sudo usermod -aG docker $USER
```

**`exec: pg_dump: executable file not found in container`**

The dump tool is missing from the container image. Use a full database image (e.g., `postgres:16`) rather than a slim variant, or install the tools in the container.

**Container not found**

Double-check the container name with `docker ps`. The name is case-sensitive.
