Synology (DSM 7.2 and later)
Container Manager → Project → Create. Paste docker-compose.yml and use real paths, for example /volume1/docker/aria2/config and /volume1/downloads. Put the Dockerfile in the same project folder.
An always-on aria2 in a container that survives restarts, runs a script when a download finishes, reports its health, and can be reached safely from anywhere. Four short files, and we ran every one of them.
One container running aria2c. Everything worth keeping lives in two folders on the host, so you can rebuild or update the container without losing anything.
./config./downloads
/configaria2.conf, the session file, the log, the DHT cache and your hook script/downloadsFinished and partial downloads6800/tcpJSON-RPC: WebUIs and apps control aria2 here6888/tcp + udpBitTorrent peers and DHTCreate /opt/aria2 (or any folder) and put these files in it. They are exactly the files we tested.
/opt/aria2/DockerfileA small Alpine image with aria2 1.37.0. It creates the session file before aria2 starts, because aria2 refuses to start without it.
FROM alpine:3.20
RUN apk add --no-cache aria2 ca-certificates tzdata
VOLUME ["/config", "/downloads"]
EXPOSE 6800 6888 6888/udp
# aria2 will not start if the session file is missing, so create it first
ENTRYPOINT ["sh", "-c", "touch /config/aria2.session && exec aria2c --conf-path=/config/aria2.conf"]
/opt/aria2/docker-compose.ymlMounts the two folders, publishes the ports and checks every minute that aria2 answers. The healthcheck uses system.listMethods, which needs no secret.
services:
aria2:
build: .
container_name: aria2
restart: unless-stopped
volumes:
- ./config:/config
- ./downloads:/downloads
ports:
- "6800:6800"
- "6888:6888"
- "6888:6888/udp"
healthcheck:
test: ["CMD-SHELL", "wget -qO- --post-data='{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"system.listMethods\"}' http://127.0.0.1:6800/jsonrpc | grep -q aria2.addUri"]
interval: 60s
timeout: 10s
retries: 3
/opt/aria2/config/aria2.confMounted, not built into the image: edit it and restart, with no rebuild. Change rpc-secret before the first start.
dir=/downloads
continue=true
file-allocation=falloc
max-concurrent-downloads=5
max-connection-per-server=16
split=16
min-split-size=1M
disk-cache=64M
# Remote control. Inside a container aria2 must listen on all interfaces;
# docker-compose.yml decides who can reach the port.
enable-rpc=true
rpc-listen-all=true
rpc-listen-port=6800
rpc-allow-origin-all=true
rpc-secret=CHANGE_ME_TO_A_LONG_RANDOM_SECRET
# BitTorrent. These ports must match docker-compose.yml.
listen-port=6888
dht-listen-port=6888
enable-dht=true
enable-peer-exchange=true
seed-ratio=1.0
dht-file-path=/config/dht.dat
# Unfinished downloads survive restarts and image updates.
input-file=/config/aria2.session
save-session=/config/aria2.session
save-session-interval=60
# Run a script when a download finishes, and keep a log.
on-download-complete=/config/on-complete.sh
log=/config/aria2.log
log-level=notice
/opt/aria2/config/on-complete.shRuns after each finished download. This one writes a line to completed.log; replace it with whatever you need (move files, send a notification).
#!/bin/sh
# aria2 passes: $1 = GID, $2 = number of files, $3 = path of the first file
echo "$(date -u +%FT%TZ) finished $3 ($2 file(s), gid $1)" >> /config/completed.log
Build the image and start the container:
mkdir -p /opt/aria2/config /opt/aria2/downloadscd /opt/aria2# Save Dockerfile and docker-compose.yml here, aria2.conf and on-complete.sh in config/chmod +x config/on-complete.shdocker compose up -d --builddocker compose ps --format "{{.Name}} {{.Status}}"aria2 Up 4 seconds (health: starting)
Check that aria2 answers, with your own secret:
curl -s http://localhost:6800/jsonrpc -d '{"jsonrpc":"2.0","id":1,"method":"aria2.getVersion","params":["token:CHANGE_ME_TO_A_LONG_RANDOM_SECRET"]}'{"id":1,"jsonrpc":"2.0","result":{"enabledFeatures":["Async DNS","BitTorrent","Firefox3 Cookie","GZip","HTTPS","Message Digest","Metalink","XML-RPC"],"version":"1.37.0"}}
Then open the online WebUI on the same computer, or any other aria2 client, and connect to port 6800 with the secret. The Alpine build has no SFTP support, which is why the feature list is one shorter than on Ubuntu.
We ran this exact stack and checked the things that usually go wrong.
docker compose restart while a 50 MB download was at 7 MB. aria2 saved the session on shutdown and continued from 17.9 MB after the restart, not from zero.
After the download, on-complete.sh wrote "finished /downloads/big.bin (1 file(s), gid …)" to /config/completed.log.
docker inspect reported "healthy" after the first check, without the secret in the compose file.
RPC calls, the browser CORS preflight and the WebSocket upgrade all passed through the nginx configuration below.
Inside the container aria2 must listen on all interfaces (rpc-listen-all=true), because Docker's port forwarding arrives from outside the container. Who can actually connect is decided by the ports line in docker-compose.yml:
| ports entry | Reachable from | Use it when |
|---|---|---|
"6800:6800" | every network the host is on | The host sits behind a home router and you want other devices at home to connect. |
"192.168.1.10:6800:6800" | one network interface (use your host's LAN address) | The host has a public IP as well as a LAN address. |
"127.0.0.1:6800:6800" | the host itself only | A reverse proxy on the same host handles all outside access (below). |
Two safe ways, simplest first:
Your phone or laptop joins your home network and connects to port 6800 as if it were at home. Nothing is exposed to the internet.
nginx terminates TLS and forwards /jsonrpc to aria2, including WebSocket. Bind 6800 to 127.0.0.1 in docker-compose.yml, and keep a long rpc-secret: it is the password for everything. In the online WebUI, type https://aria2.example.com in the host field.
server {
listen 443 ssl;
server_name aria2.example.com;
ssl_certificate /etc/letsencrypt/live/aria2.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/aria2.example.com/privkey.pem;
location /jsonrpc {
proxy_pass http://127.0.0.1:6800/jsonrpc;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_read_timeout 1h;
}
}
Use a certificate from Let's Encrypt (certbot) for your domain. Do not add basic authentication on /jsonrpc: browsers send the CORS preflight without credentials, so browser-based WebUIs would stop working.
We tested on Linux. On a NAS the same compose file works; only the paths and the place you paste it differ. These steps are checked, not run.
Container Manager → Project → Create. Paste docker-compose.yml and use real paths, for example /volume1/docker/aria2/config and /volume1/downloads. Put the Dockerfile in the same project folder.
Container Station → Applications → Create, then paste the compose file. Map the folders to a shared folder.
Use the Docker Compose Manager plugin, or create the container from the template page with the same mounts and ports.
The container runs as root by default. If other apps (Plex, Jellyfin, *arr) must manage the files, add user: "1000:1000" (your user and group IDs) and run chown -R 1000:1000 config downloads first.
Update aria2 and the base image when Alpine publishes new packages. Your config, session and downloads stay in the mounted folders:
docker compose build --pulldocker compose up -d
Keep public trackers fresh with the update script from the tracker list, pointed at the mounted config, then restart (the session is saved on shutdown, so running downloads continue):
0 4 * * 1 CONF=/opt/aria2/config/aria2.conf sh /opt/aria2/update-trackers.sh && docker restart aria2
To back up, copy ./config. It holds everything except the downloads themselves.
Another container or program already uses port 6800 on the host. Stop it, or publish a different host port, for example "6801:6800", and connect to 6801.
You set user: to an account that cannot write to the config folder. Run chown -R 1000:1000 config downloads (with your IDs) on the host, or remove the user: line.
Harmless. Docker networks have no IPv6 by default, so aria2 cannot open the IPv6 socket; the line just before it says IPv4 RPC: listening on TCP port 6800, and RPC works.
Check docker compose ps (the container must be up), that the secret matches rpc-secret, and that you connect to the host's address, not the container's. From an HTTPS page such as aria2.org, browsers only allow localhost over plain HTTP; for anything else use the reverse proxy and an https:// address.
Forward port 6888 for TCP and UDP on your router to the host, and add fresh trackers from the tracker list. DHT needs a few minutes to fill up the first time; its cache lives in /config/dht.dat, so later starts are quicker.
The Dockerfile has five instructions and uses Alpine's own aria2 package, so you can read everything that runs. Community images such as p3terx/aria2-pro add tracker updates and other scripts; they are a valid shortcut if you check their documentation.
No. The online WebUI, AriaNg or any other client talks to aria2 directly over RPC. See GUIs and extensions.
Yes. aria2.conf is mounted from ./config; edit it and run docker restart aria2. Only a new aria2 version needs a rebuild.
Alpine provides aria2 for ARM, so the same files build on a Pi. Use a smaller disk-cache and fewer concurrent downloads on models with little memory. We did not test on a Pi.