crazy-max / docker-rtorrent-rutorrent

rTorrent and ruTorrent Docker image
MIT License
483 stars 106 forks source link
alpine-linux docker nginx rtorrent rutorrent traefik

Latest Version Build Status Docker Stars Docker Pulls
Become a sponsor Donate Paypal

About

stickz rTorrent with ruTorrent Docker image.

[!TIP] Want to be notified of new releases? Check out šŸ”” Diun (Docker Image Update Notifier) project!


Features

Build locally

git clone https://github.com/crazy-max/docker-rtorrent-rutorrent.git
cd docker-rtorrent-rutorrent

# Build image and output to docker (default)
docker buildx bake

# Build image
docker buildx bake image

# Build multi-platform image
docker buildx bake image-all

Image

Registry Image
Docker Hub crazymax/rtorrent-rutorrent
GitHub Container Registry ghcr.io/crazy-max/rtorrent-rutorrent

Following platforms for this image are available:

$ docker run --rm mplatform/mquery crazymax/rtorrent-rutorrent:latest
Image: crazymax/rtorrent-rutorrent:latest
 * Manifest List: Yes
 * Supported platforms:
   - linux/amd64
   - linux/arm/v6
   - linux/arm/v7
   - linux/arm64

Environment variables

General

rTorrent

ruTorrent

Volumes

:warning: Note that the volumes should be owned by the user/group with the specified PUID and PGID. If you don't give the volumes correct permissions, the container may not start.

Ports

:warning: Port p+1 defined for XMLRPC_PORT, RUTORRENT_PORT and WEBDAV_PORT will also be reserved for healthcheck. (e.g. if you define RUTORRENT_PORT=8080, port 8081 will be reserved)

Usage

Docker Compose

Docker compose is the recommended way to run this image. Copy the content of folder examples/compose in /var/rtorrent-rutorrent/ on your host for example. Edit the compose file with your preferences and run the following command:

mkdir data downloads passwd
chown ${PUID}:${PGID} data downloads passwd
docker compose up -d
docker compose logs -f

Command line

You can also use the following minimal command:

mkdir data downloads passwd
chown ${PUID}:${PGID} data downloads passwd
docker run -d --name rtorrent_rutorrent \
  --ulimit nproc=65535 \
  --ulimit nofile=32000:40000 \
  -p 6881:6881/udp \
  -p 8000:8000 \
  -p 8080:8080 \
  -p 9000:9000 \
  -p 50000:50000 \
  -v $(pwd)/data:/data \
  -v $(pwd)/downloads:/downloads \
  -v $(pwd)/passwd:/passwd \
  crazymax/rtorrent-rutorrent:latest

Notes

XMLRPC through nginx

rTorrent 0.9.7+ has a built-in daemon mode disabling the user interface, so you can only control it via XMLRPC. Nginx will route XMLRPC requests to rtorrent through port 8000. These requests can be secured with basic authentication through the /passwd/rpc.htpasswd file in which you will need to add a username with his password. See below to populate this file with a user / password.

WebDAV

WebDAV allows you to retrieve your completed torrent files in /downloads/complete on port 9000. Like XMLRPC, these requests can be secured with basic authentication through the /passwd/webdav.htpasswd file in which you will need to add a username with his password. See below to populate this file with a user / password.

Populate .htpasswd files

For ruTorrent basic auth, XMLRPC through nginx and WebDAV on completed downloads, you can populate .htpasswd files with the following command:

docker run --rm -it httpd:2.4-alpine htpasswd -Bbn <username> <password> >> $(pwd)/passwd/webdav.htpasswd

Htpasswd files used:

Bootstrap config .rtlocal.rc

When rTorrent is started the bootstrap config /etc/rtorrent/.rtlocal.rc is imported. This configuration cannot be changed unless you rebuild the image or overwrite these elements in your .rtorrent.rc. Here are the particular properties of this file:

Override or add a ruTorrent plugin/theme

You can add a plugin for ruTorrent in /data/rutorrent/plugins/. If you add a plugin that already exists in ruTorrent, it will be removed from ruTorrent core plugins and yours will be used. And you can also add a theme in /data/rutorrent/themes/. The same principle as for plugins will be used if you want to override one.

:warning: Container has to be restarted to propagate changes

Edit a ruTorrent plugin configuration

As you probably know, plugin configuration is not outsourced in ruTorrent. Loading the configuration of a plugin is done via a conf.php file placed at the root of the plugin folder. To solve this issue with Docker, a special folder has been created in /data/rutorrent/plugins-conf to allow you to configure plugins. For example to configure the diskspace plugin, you will need to create the /data/rutorrent/plugins-conf/diskspace.php file with your configuration:

<?php

$diskUpdateInterval = 10;   // in seconds
$notifySpaceLimit = 512;    // in Mb
$partitionDirectory = null; // if null, then we will check rtorrent download directory (or $topDirectory if rtorrent is unavailable)
                // otherwise, set this to the absolute path for checked partition. 

:warning: Container has to be restarted to propagate changes

Increase Docker timeout to allow rTorrent to shutdown gracefully

After issuing a shutdown command, Docker waits 10 seconds for the container to exit before it is killed. If you are a seeding many torrents, rTorrent may be unable to gracefully close within that time period. As a result, rTorrent is closed forcefully and the lockfile isn't removed. This stale lockfile will prevent rTorrent from restarting until the lockfile is removed manually.

The timeout period can be extended by either adding the parameter -t XX to the docker command or stop_grace_period: XXs in compose.yml, where XX is the number of seconds to wait for a graceful shutdown.

WAN IP address

WAN_IP is the public IP address sent to the tracker. In the majority of cases you don't need to set it as it will be automatically determined by the tracker.

But it can be sometimes required to enforce the public IP address when you are behind a VPN where an erroneous IP is sometimes reported.

You can also use the WAN_IP_CMD environment variable to specify a command to resolve your public IP address. Here are some commands you can use:

Configure rTorrent session saving

RT_SESSION_SAVE_SECONDS is the seconds between writing torrent information to disk. The default is 3600 seconds which equals 1 hour. rTorrent has a bad default of 20 minutes. Twenty minutes is bad for the lifespan of SSDs and greatly reduces torrent throughput.

It is no longer possible to lose torrents added through ruTorrent on this docker container. Only torrent statistics are lost during a crash. (Ratio, Total Uploaded & Downloaded etc.)

Higher values will reduce disk usage, at the cost of minor stat loss during a crash. Consider increasing to 10800 seconds (3 hours) if running thousands of torrents.

rTorrent tracker scrape patch

RT_TRACKER_DELAY_SCRAPE specifies whether to delay tracker announces at rTorrent startup. The default value is true. There are two main benefits to keeping this feature enabled:

1) Software Stability: rTorrent will not crash or time-out with tens of thousands of trackers. 2) Immediate Access: ruTorrent can be accessed immediately after rTorrent is started.

rTorrent send receive buffers

Overriding the default TCP rmem and wmem values for rTorrent improves torrent throughput.

Recommended values:

Memory is better spent elsewhere except under limited circumstances for high memory and speed conditions. The default values should not be increased, unless both the memory and speed requirements are met. These values of system memory are also recommended based on the port speed for rTorrent to reduce disk usage.

rTorrent disk space preallocation

Preallocate disk space for contents of a torrent

Acceptable values:

This feature is disabled by default becuase it only benefits HDDs. By allocating files in sequence we can increase the read speed for seeding.

The first type "1" only allocates disk space for files which start downloading. Use where disk space is more important than speed. Or you intend to download selective torrent files.

The second type "2" allocates disk space for the entire torrent, whether it's downloaded or not. This method is faster than "1" becuase it reduces random reads for the entire torrent. Use where speed is more important than disk space. Or you intend to download 100% of every torrent.

Upgrade

To upgrade, pull the newer image and launch the container:

docker compose pull
docker compose up -d

Contributing

Want to contribute? Awesome! The most basic way to show your support is to star the project, or to raise issues. You can also support this project by becoming a sponsor on GitHub or by making a PayPal donation to ensure this journey continues indefinitely!

Thanks again for your support, it is much appreciated! :pray:

License

MIT. See LICENSE for more details.