bitmagnet with Docker Compose
A self-hosted BitTorrent indexer, DHT crawler, content classifier and torrent search engine with web UI, GraphQL API and Servarr stack integration. In the project's words: bitmagnet on GitHub (repository description) checked 2026-10-09
Runs on: amd64, arm64, arm/v7, 386, arm/v6, ppc64le, s390x from each image's registry manifest, checked 2026-10-09; a CPU counts only if every image has a build for it. Image by image
Add bitmagnet to the builder to use your own domain, get its passwords generated in your browser, and combine it with other apps in one file.
What bitmagnet needs
Only figures bitmagnet's own documentation publishes, each linked to the page it is on. Where the project gives no number, this page does not invent one.
| Resource | Minimum | Recommended |
|---|---|---|
| RAM | 1.3 GB | not stated |
| Published as "a rough guide": around 300 MB for bitmagnet and at least 1 GB for its Postgres database, which "will run fastest when it has plenty of RAM and a fast disk, preferably a SSD". Source: bitmagnet docs: FAQ (not a public service, VPN, system requirements) checked 2026-10-09 | ||
| CPU | The project publishes no figure | |
| Disk | not stated | 80 GB |
| Published as roughly 80 GB per 10 million torrents, "several months of crawling", with "no upper limit": the index keeps growing while the crawler runs. Source: bitmagnet docs: FAQ (not a public service, VPN, system requirements) checked 2026-10-09 | ||
Which hardware bitmagnet has images for
Read from each image's manifest list in its registry (anonymous, read-only) when this page was built. An app counts for a CPU only if every one of its images lists it.
- x86-64 PC or NAS (
linux/amd64): every image has a build. - Raspberry Pi 4/5, 64-bit OS (
linux/arm64): every image has a build. - Raspberry Pi 3 or Zero 2 W, 32-bit OS (
linux/arm/v7): every image has a build.
| Service | Image | Platforms in the manifest | Digest | Registry | Checked |
|---|---|---|---|---|---|
bitmagnet | ghcr.io/bitmagnet-io/bitmagnet:latest | amd64/v3, 386, ppc64le, arm/v6, arm/v7, arm64, s390x, amd64, amd64/v2 | sha256:b6373349a30193b436ce6b05e21f91aa4934074268105dded1f3b065b8c86f19 | ghcr.io | 2026-10-09 |
postgres | postgres:16-alpine | amd64, arm/v6, arm/v7, arm64, 386, ppc64le, riscv64, s390x | sha256:721873c34ceb9f8d8fc265984940dc982404c105f19ad51be9fdc5970a6080ea | registry-1.docker.io | 2026-09-26 |
docker-compose.yml
This is exactly what the builder writes for bitmagnet alone on example.org: the official definition with its published ports removed except 3334:3334/tcp and 3334:3334/udp, which cannot go through a web proxy (see below), and Caddy added in front. Every ${VARIABLE} is defined in the .env below.
# docker-compose.yml built at dankhost.com for: bitmagnet # Each app block is its official compose definition. Only the names were prefixed with # the app slug (services, containers, volumes, bind folders, .env variables) so any set of # apps can share one file; other differences are listed under "Changed:" in each block. # Caddy publishes 80 and 443. The only other published ports, each labelled where # it is written: 3334/tcp (bitmagnet: BitTorrent over TCP), 3334/udp (bitmagnet: DHT and BitTorrent over UDP). # Secrets live in .env next to this file. services: # ---- Caddy: the one reverse proxy, HTTPS certificates from Let's Encrypt ---- # Source: https://caddyserver.com/docs/running (checked 2026-09-23) # Source: https://github.com/dani-garcia/vaultwarden/wiki/Using-Docker-Compose (checked 2026-09-23) # Caddyfile goes in ./caddy/Caddyfile. Fixed address 172.30.0.2 so apps can trust it exactly. caddy: image: "caddy:2" container_name: "caddy" restart: "unless-stopped" ports: - "80:80" - "443:443" - "443:443/udp" volumes: - "./caddy:/etc/caddy" - "caddy-data:/data" - "caddy-config:/config" networks: proxy: ipv4_address: "172.30.0.2" # ---- bitmagnet (bitmagnet.example.org) ---- # Source: https://bitmagnet.io/setup/installation.html (checked 2026-10-09) # Source: https://bitmagnet.io/faq.html (checked 2026-10-09) # Source: https://bitmagnet.io/guides/backup-restore-merge.html (checked 2026-10-09) # Changed: Removed the documented '3333:3333' port and both container_names; Caddy reaches bitmagnet:3333 on the proxy network. 3334/tcp and 3334/udp stay published, labelled. # POSTGRES_PASSWORD, postgres in the file on both services, is a generated value in .env shared by both. # TMDB_API_KEY, commented out in the file, is left out: bitmagnet then shares a default key limited to 1 request per second (Configuration page); add your own to bitmagnet's environment if you import or classify a lot. # PORT OUTSIDE THE PROXY 3334/tcp: the crawler's BitTorrent port, which the minimal example publishes as "BitTorrent ports" next to the web UI on 3333. BitTorrent is not HTTP, so it cannot go through the proxy. # PORT OUTSIDE THE PROXY 3334/udp: the same port over UDP, which the DHT the crawler listens to runs on. Published beside the proxy, as in the minimal example, because no HTTP proxy carries UDP. bitmagnet: image: "ghcr.io/bitmagnet-io/bitmagnet:latest" container_name: "bitmagnet" restart: "unless-stopped" environment: POSTGRES_HOST: "postgres" POSTGRES_PASSWORD: "${BITMAGNET_POSTGRES_PASSWORD}" volumes: - "./bitmagnet/config:/root/.config/bitmagnet" command: - "worker" - "run" - "--keys=http_server" - "--keys=queue_server" - "--keys=dht_crawler" depends_on: bitmagnet-postgres: condition: "service_healthy" ports: - "3334:3334/tcp" # BitTorrent over TCP - "3334:3334/udp" # DHT and BitTorrent over UDP networks: proxy: {} bitmagnet-backend: {} bitmagnet-postgres: image: "postgres:16-alpine" container_name: "bitmagnet-postgres" restart: "unless-stopped" volumes: - "./bitmagnet/data/postgres:/var/lib/postgresql/data" environment: POSTGRES_PASSWORD: "${BITMAGNET_POSTGRES_PASSWORD}" POSTGRES_DB: "bitmagnet" PGUSER: "postgres" shm_size: "1g" healthcheck: test: - "CMD-SHELL" - "pg_isready" start_period: "20s" interval: "10s" networks: bitmagnet-backend: aliases: - "postgres" networks: # Pinned so the trusted-proxy address given to each app (172.30.0.2) is exact. # If "docker compose up" reports "Pool overlaps", change 172.30.0 here, in Caddy's # ipv4_address and in every trusted-proxy value to a free 172.x.0 range. proxy: ipam: config: - subnet: "172.30.0.0/24" ip_range: "172.30.0.128/25" gateway: "172.30.0.1" bitmagnet-backend: internal: true volumes: caddy-data: caddy-config:
Caddyfile save as caddy/Caddyfile
Caddy gets and renews the HTTPS certificate for bitmagnet.example.org by itself once the DNS record points at your server and ports 80 and 443 reach it.
# Caddyfile built at dankhost.com. Save it as ./caddy/Caddyfile next to docker-compose.yml.
# Caddy gets and renews a Let's Encrypt certificate for each name below by itself,
# once the DNS records point at this server and ports 80 and 443 reach it.
# bitmagnet
bitmagnet.example.org {
reverse_proxy bitmagnet:3333
}
.env
The secret is left blank here on purpose: a password printed on a public page is the same for everyone who copies it. The builder fills it with random letters and digits made in your browser.
# .env for bitmagnet, from dankhost.com/app/bitmagnet/. Fill the blank secret before starting. # Keep this file private (chmod 600). # bitmagnet # 32 random letters and digits: the builder fills this in your browser BITMAGNET_POSTGRES_PASSWORD=
What bitmagnet needs beyond the proxy
Every other app in the builder is reached only through the proxy on ports 80 and 443. bitmagnet also needs these ports on the server itself, because they carry traffic that is not HTTP. The compose file labels each with a # PORT OUTSIDE THE PROXY comment.
3334:3334/tcp(BitTorrent over TCP): the crawler's BitTorrent port, which the minimal example publishes as "BitTorrent ports" next to the web UI on 3333. BitTorrent is not HTTP, so it cannot go through the proxy.3334:3334/udp(DHT and BitTorrent over UDP): the same port over UDP, which the DHT the crawler listens to runs on. Published beside the proxy, as in the minimal example, because no HTTP proxy carries UDP.- Port 3334 (TCP and UDP) is the crawler's side of the BitTorrent network. The docs publish it and say nothing about forwarding it on a router; the web UI needs only the proxy.
Changes from the official file
Besides prefixing every service, container, volume, folder and variable with bitmagnet (so any set of apps can share one file), these are all the differences from what the project documents:
- Removed the documented '3333:3333' port and both container_names; Caddy reaches bitmagnet:3333 on the proxy network. 3334/tcp and 3334/udp stay published, labelled.
- POSTGRES_PASSWORD, postgres in the file on both services, is a generated value in .env shared by both.
- TMDB_API_KEY, commented out in the file, is left out: bitmagnet then shares a default key limited to 1 request per second (Configuration page); add your own to bitmagnet's environment if you import or classify a lot.
Notes for bitmagnet behind the proxy
- bitmagnet has no login. Its FAQ: it is not meant as a public service, because "The UI and API allow destructive actions". Put a password on the proxy, or reach it only from your network.
- The FAQ recommends a VPN: the crawler fetches metadata about whatever is shared on the DHT, including copyrighted and illegal material, and anti-piracy tools may flag that. The repository's full docker-compose.yml routes bitmagnet through a gluetun VPN container; this is the minimal example without it.
- Torrents appear in the web UI within about ten minutes of the first start (the FAQ: the UI caches for 10 minutes; the refresh button skips the cache).
- The tag is latest; the docs' upgrade steps pull whatever is newest.
How to run it
- At your DNS provider, add an A record named
bitmagneton your domain pointing at the server's public IP address, and forward TCP 80, TCP 443 and UDP 443 to it. For bitmagnet, port 3334 (TCP and UDP) is the crawler's side of the BitTorrent network. The docs publish it and say nothing about forwarding it on a router; the web UI needs only the proxy. - Save the three files in one folder:
docker-compose.ymland.envside by side, the Caddyfile at./caddy/Caddyfile. Replaceexample.orgwith your domain in the Caddyfile, the compose file and the .env, or let the builder do it. - Fill the blank
BITMAGNET_POSTGRES_PASSWORDin.env. The builder generates it; on the server,tr -dc A-Za-z0-9 </dev/urandom | head -c 32prints 32 random letters and digits. Thenchmod 600 .env. - Start it:
docker compose up -d docker compose logs -f caddy # watch the certificate arrive
- Open the new address (
bitmagnet.plus your domain) in a browser and follow the notes above.
Back it up
bitmagnet's Backup, Restore & Merge guide: pg_dump of "the critical bitmagnet data" with --data-only, so the file can be loaded into a new or existing installation of the same version after its migrations have run.
Below is the BACKUP.md the builder writes next to the compose file above: which of its folders and volumes hold data, the dump command the project documents, rewritten for this file's service names, what to copy with which container stopped, and a restore check. Pick more apps in the builder and it covers them all in one file.
# BACKUP.md built at dankhost.com for: bitmagnet
What to copy from the docker-compose.yml built with this file, the database dump each project documents (rewritten for the service names in that file), what to copy with which container stopped, and how to check the result. Run every command in the folder that holds docker-compose.yml.
The folders are owned by the containers' users: put sudo in front of tar if it says "Permission denied". Named volumes live under /var/lib/docker/volumes, not next to the compose file, so they are copied through a throwaway ubuntu container (Docker's documented --volumes-from method). tar makes a full copy each run; for large folders an incremental tool (restic, borg, rsync) saves time and space.
Never run "docker compose down -v" on this file: it deletes the named volumes of every app in it.
## Before you start
BACKUP=/mnt/backup/selfhost # change this: a disk or machine other than this server's system disk
mkdir -p "$BACKUP"
## Every time: the three stack files
tar czf "$BACKUP/stack-files.tar.gz" docker-compose.yml .env caddy
.env holds the database passwords and secret keys the apps were set up with; keep this archive as private as the data.
## Caddy (the reverse proxy)
Caddy's docs: 'The data directory must not be treated as a cache.' It holds the TLS certificates and their private keys; without it Caddy has to ask Let's Encrypt for every certificate again.
- caddy-data (named volume, /data in caddy)
BACK UP: TLS certificates, private keys, OCSP staples.
- caddy-config (named volume, /config in caddy)
SKIP: the last active configuration, kept for 'caddy run --resume', which this setup does not use: it starts from the Caddyfile.
- ./caddy (/etc/caddy in caddy)
IN stack-files.tar.gz: the Caddyfile, copied with the stack files above.
Copy (Caddy keeps serving while you copy):
docker run --rm --volumes-from caddy -v "$BACKUP":/backup ubuntu tar cvf /backup/caddy-data.tar /data
Restore check:
tar tf "$BACKUP/caddy-data.tar" > /dev/null && echo OK
docker run --rm --volumes-from caddy -v "$BACKUP":/backup ubuntu bash -c "cd /data && tar xvf /backup/caddy-data.tar --strip 1"
Sources:
- Caddy docs: Conventions, Data directory: https://caddyserver.com/docs/conventions#data-directory (checked 2026-09-24)
- Docker docs: Volumes, Back up, restore, or migrate data volumes: https://docs.docker.com/engine/storage/volumes/#back-up-restore-or-migrate-data-volumes (checked 2026-09-24)
## bitmagnet
bitmagnet's Backup, Restore & Merge guide: pg_dump of "the critical bitmagnet data" with --data-only, so the file can be loaded into a new or existing installation of the same version after its migrations have run.
What this compose mounts:
- ./bitmagnet/config (/root/.config/bitmagnet in bitmagnet)
BACK UP: config.yml, if you have written one (bitmagnet's settings beyond the environment).
- ./bitmagnet/data/postgres (/var/lib/postgresql/data in bitmagnet-postgres)
COVERED BY THE COMMAND BELOW: the Postgres data files: every torrent, file list and classification. The dump below is the copy to keep.
1. Database dump for bitmagnet-postgres:
docker compose exec -T bitmagnet-postgres pg_dump --column-inserts --data-only --on-conflict-do-nothing --rows-per-insert=1000 --table=metadata_sources --table=content --table=content_attributes --table=content_collections --table=content_collections_content --table=torrent_sources --table=torrents --table=torrent_files --table=torrent_hints --table=torrent_contents --table=torrent_tags --table=torrents_torrent_sources --table=key_values bitmagnet > "$BACKUP/bitmagnet.sql"
The guide's command, run in this file's database service, whose PGUSER is postgres.
2. Copy (bitmagnet keeps running):
pg_dump reads a consistent snapshot while the crawler keeps writing.
tar czf "$BACKUP/bitmagnet-config.tar.gz" ./bitmagnet/config
Restore check:
grep -c 'PostgreSQL database dump complete' "$BACKUP/bitmagnet.sql" # 1 means pg_dump finished
tar tzf "$BACKUP/bitmagnet-config.tar.gz" > /dev/null && echo OK
Put a copy back (with bitmagnet stopped):
tar xzf "$BACKUP/bitmagnet-config.tar.gz" # recreates ./bitmagnet/config; move the old folder aside first
Into a running install of the same bitmagnet version (the guide: restoring merges with what is there):
docker compose exec -T bitmagnet-postgres psql bitmagnet < "$BACKUP/bitmagnet.sql"
Sources:
- bitmagnet docs: Backup, Restore & Merge (pg_dump --data-only, psql): https://bitmagnet.io/guides/backup-restore-merge.html (checked 2026-10-09)
- Docker docs: Volumes, Back up, restore, or migrate data volumes: https://docs.docker.com/engine/storage/volumes/#back-up-restore-or-migrate-data-volumes (checked 2026-10-09)
Update it
What docker compose pull does depends only on how each image line in the compose file above is tagged. For bitmagnet as this page writes it:
| Service | Image | How it is pinned | What docker compose pull does |
|---|---|---|---|
caddy | caddy:2 | Major version only (tag 2) | Takes the newest image tagged 2: minor and patch releases of 2, never 3. A new major version needs a tag edit. |
bitmagnet | ghcr.io/bitmagnet-io/bitmagnet:latest | Not pinned: moving tag latest | Moves to the newest image published as latest, which can be a new major version. |
bitmagnet-postgres database | postgres:16-alpine | Major version only (tag 16-alpine) | Takes the newest image tagged 16-alpine: minor and patch releases of 16, never 17. A new major version needs a tag edit. |
Do not raise the major version of bitmagnet-postgres by editing its tag. Keep its tag, 16-alpine, as it is when you update bitmagnet.
PostgreSQL's docs: a new major version may change how data is stored on disk, so a data folder written by an older major version will not start under a newer one (the server refuses it). Moving needs a dump and restore (pg_dumpall, then load the dump into the new version) or pg_upgrade. Minor releases of the same major version never change the storage format. Source: PostgreSQL docs: Upgrading a PostgreSQL Cluster checked 2026-09-30
What bitmagnet's docs say about updating
bitmagnet's Installation page, "To upgrade your installation":
docker compose down bitmagnet docker pull ghcr.io/bitmagnet-io/bitmagnet:latest docker compose up -d bitmagnet
The steps
- Back up first, as in Back it up above. An update can migrate bitmagnet's data on its first start and its database with it; the copy is the way back.
- Download the new images. Running containers are not touched yet:
docker compose pull
- Recreate the containers whose image changed. Volumes and bind-mounted folders stay as they are:
docker compose up -d
- Watch bitmagnet start (Ctrl+C stops following the log, not the app):
docker compose logs -f bitmagnet
- Optional: remove the old images the pull left without a tag. This covers every stack on the machine, not only this one:
docker image prune
Locked out? Reset the admin password
bitmagnet has no accounts and no login, so there is no password to reset.
Its FAQ says it was "designed to be self-hosted" and is not meant as a public service, because "The UI and API allow destructive actions". Anyone who can reach the address can use it, so put a password on the proxy. Source: bitmagnet docs: FAQ (not a public service, VPN, system requirements) read 2026-10-09
Sources
Every page below was fetched on the date shown.
- bitmagnet on GitHub (repository description) checked 2026-10-09 (what it does)
- bitmagnet docs: FAQ (not a public service, VPN, system requirements) checked 2026-10-09 (hardware requirements, compose definition and proxy settings)
- bitmagnet docs: Installation (minimal docker-compose.yml, ports 3333 and 3334, upgrading) checked 2026-10-09 (compose definition and proxy settings, update notes)
- bitmagnet docs: Backup, Restore & Merge (pg_dump --data-only, psql) checked 2026-10-09 (compose definition and proxy settings, backup plan)
- Caddy docs: Keep Caddy running (Docker Compose section) checked 2026-09-23 (Caddy)
- Vaultwarden wiki: Caddy with HTTP challenge (uses the caddy:2 image) checked 2026-09-23 (Caddy)
- Docker docs: Volumes, Back up, restore, or migrate data volumes checked 2026-10-09 (backup plan)
- Caddy docs: Conventions, Data directory checked 2026-09-24 (backup plan)
- PostgreSQL docs: Upgrading a PostgreSQL Cluster checked 2026-09-30 (database upgrade)
- Docker docs: docker compose pull checked 2026-09-30 (update steps)
- Docker docs: docker compose up (recreates changed containers, keeps volumes) checked 2026-09-30 (update steps)
- Docker docs: docker image prune checked 2026-09-30 (update steps)