docker – Blame information for rev 62

Subversion Repositories:
Rev:
Rev Author Line No. Line
62 office 1 <p align="center"><a href="https://github.com/crazy-max/docker-rtorrent-rutorrent" target="_blank"><img height="128" src="https://raw.githubusercontent.com/crazy-max/docker-rtorrent-rutorrent/master/.github/docker-rtorrent-rutorrent.jpg"></a></p>
2  
3 <p align="center">
4 <a href="https://hub.docker.com/r/crazymax/rtorrent-rutorrent/tags?page=1&ordering=last_updated"><img src="https://img.shields.io/github/v/tag/crazy-max/docker-rtorrent-rutorrent?label=version&style=flat-square" alt="Latest Version"></a>
5 <a href="https://github.com/crazy-max/docker-rtorrent-rutorrent/actions?workflow=build"><img src="https://img.shields.io/github/actions/workflow/status/crazy-max/docker-rtorrent-rutorrent/build.yml?branch=master&label=build&logo=github&style=flat-square" alt="Build Status"></a>
6 <a href="https://hub.docker.com/r/crazymax/rtorrent-rutorrent/"><img src="https://img.shields.io/docker/stars/crazymax/rtorrent-rutorrent.svg?style=flat-square&logo=docker" alt="Docker Stars"></a>
7 <a href="https://hub.docker.com/r/crazymax/rtorrent-rutorrent/"><img src="https://img.shields.io/docker/pulls/crazymax/rtorrent-rutorrent.svg?style=flat-square&logo=docker" alt="Docker Pulls"></a>
8 <br /><a href="https://github.com/sponsors/crazy-max"><img src="https://img.shields.io/badge/sponsor-crazy--max-181717.svg?logo=github&style=flat-square" alt="Become a sponsor"></a>
9 <a href="https://www.paypal.me/crazyws"><img src="https://img.shields.io/badge/donate-paypal-00457c.svg?logo=paypal&style=flat-square" alt="Donate Paypal"></a>
10 </p>
11  
12 ## About
13  
14 [rTorrent](https://github.com/rakshasa/rtorrent) with [ruTorrent](https://github.com/Novik/ruTorrent)
15 Docker image.
16  
17 > [!TIP]
18 > Want to be notified of new releases? Check out 🔔 [Diun (Docker Image Update Notifier)](https://github.com/crazy-max/diun)
19 > project!
20  
21 ___
22  
23 * [Features](#features)
24 * [Build locally](#build-locally)
25 * [Image](#image)
26 * [Environment variables](#environment-variables)
27 * [General](#general)
28 * [rTorrent](#rtorrent)
29 * [ruTorrent](#rutorrent)
30 * [Volumes](#volumes)
31 * [Ports](#ports)
32 * [Usage](#usage)
33 * [Docker Compose](#docker-compose)
34 * [Command line](#command-line)
35 * [Notes](#notes)
36 * [XMLRPC through nginx](#xmlrpc-through-nginx)
37 * [WebDAV](#webdav)
38 * [Populate .htpasswd files](#populate-htpasswd-files)
39 * [Bootstrap config `.rtlocal.rc`](#bootstrap-config-rtlocalrc)
40 * [Override or add a ruTorrent plugin/theme](#override-or-add-a-rutorrent-plugintheme)
41 * [Edit a ruTorrent plugin configuration](#edit-a-rutorrent-plugin-configuration)
42 * [Increase Docker timeout to allow rTorrent to shutdown gracefully](#increase-docker-timeout-to-allow-rtorrent-to-shutdown-gracefully)
43 * [WAN IP address](#wan-ip-address)
44 * [Configure rTorrent session saving](#configure-rtorrent-session-saving)
45 * [Configure rTorrent tracker scrape](#rtorrent-tracker-scrape-patch)
46 * [Configure rTorrent send receive buffers](#rtorrent-send-receive-buffers)
47 * [Configure rTorrent disk space preallocation](#rtorrent-disk-space-preallocation)
48 * [Upgrade](#upgrade)
49 * [Contributing](#contributing)
50 * [License](#license)
51  
52 ## Features
53  
54 * Run as non-root user
55 * Multi-platform image
56 * Latest [rTorrent](https://github.com/rakshasa/rtorrent) / [libTorrent](https://github.com/rakshasa/libtorrent) release compiled from source
57 * Latest [ruTorrent](https://github.com/Novik/ruTorrent) release
58 * Domain name resolving enhancements with [c-ares](https://github.com/rakshasa/rtorrent/wiki/Performance-Tuning#rtrorrent-with-c-ares) and [UDNS](https://www.corpit.ru/mjt/udns.html) for asynchronous DNS requests
59 * Enhanced [rTorrent config](rootfs/tpls/.rtorrent.rc) and bootstraping with a [local config](rootfs/tpls/etc/rtorrent/.rtlocal.rc)
60 * XMLRPC through nginx over SCGI socket (basic auth optional)
61 * WebDAV on completed downloads (basic auth optional)
62 * Ability to add a custom ruTorrent plugin / theme
63 * Allow persisting specific configuration for ruTorrent plugins
64 * ruTorrent [GeoIP2 plugin](https://github.com/Micdu70/geoip2-rutorrent)
65 * [mktorrent](https://github.com/pobrn/mktorrent) installed for ruTorrent create plugin
66 * [Traefik](https://github.com/containous/traefik-library-image) Docker image as reverse proxy and creation/renewal of Let's Encrypt certificates (see [this template](examples/traefik))
67 * [geoip-updater](https://github.com/crazy-max/geoip-updater) Docker image to download MaxMind's GeoIP2 databases on a time-based schedule for geolocation
68  
69 ## Build locally
70  
71 ```shell
72 git clone https://github.com/crazy-max/docker-rtorrent-rutorrent.git
73 cd docker-rtorrent-rutorrent
74  
75 # Build image and output to docker (default)
76 docker buildx bake
77  
78 # Build image
79 docker buildx bake image
80  
81 # Build multi-platform image
82 docker buildx bake image-all
83 ```
84  
85 ## Image
86  
87 | Registry | Image |
88 |---------------------------------------------------------------------------------------------------------------|-----------------------------------------|
89 | [Docker Hub](https://hub.docker.com/r/crazymax/rtorrent-rutorrent/) | `crazymax/rtorrent-rutorrent` |
90 | [GitHub Container Registry](https://github.com/users/crazy-max/packages/container/package/rtorrent-rutorrent) | `ghcr.io/crazy-max/rtorrent-rutorrent` |
91  
92 Following platforms for this image are available:
93  
94 ```
95 $ docker buildx imagetools inspect crazymax/rtorrent-rutorrent --format "{{json .Manifest}}" | \
96 jq -r '.manifests[] | select(.platform.os != null and .platform.os != "unknown") | .platform | "\(.os)/\(.architecture)\(if .variant then "/" + .variant else "" end)"'
97  
98 linux/amd64
99 linux/arm/v6
100 linux/arm/v7
101 linux/arm64
102 ```
103  
104  
105 ## Environment variables
106  
107 ### General
108  
109 * `TZ`: The timezone assigned to the container (default `UTC`)
110 * `PUID`: rTorrent user id (default `1000`)
111 * `PGID`: rTorrent group id (default `1000`)
112 * `WAN_IP`: [Public IP address](#wan-ip-address) reported to the tracker (auto if empty)
113 * `WAN_IP_CMD`: Command to resolve the [Public IP address](#wan-ip-address)
114 * `MEMORY_LIMIT`: PHP memory limit (default `256M`)
115 * `UPLOAD_MAX_SIZE`: Upload max size (default `16M`)
116 * `CLEAR_ENV`: Clear environment in FPM workers (default `yes`)
117 * `OPCACHE_MEM_SIZE`: PHP OpCache memory consumption (default `128`)
118 * `MAX_FILE_UPLOADS`: The maximum number of files allowed to be uploaded simultaneously (default `50`)
119 * `AUTH_DELAY`: The time in seconds to wait for Basic Auth (default `0s`)
120 * `REAL_IP_FROM`: Trusted addresses that are known to send correct replacement addresses (default `0.0.0.0/32`)
121 * `REAL_IP_HEADER`: Request header field whose value will be used to replace the client address (default `X-Forwarded-For`)
122 * `LOG_IP_VAR`: Use another variable to retrieve the remote IP address for access [log_format](http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format) on Nginx. (default `remote_addr`)
123 * `LOG_ACCESS`: Output access log (default `true`)
124 * `XMLRPC_AUTHBASIC_STRING`: Message displayed during validation of XMLRPC Basic Auth (default `rTorrent XMLRPC restricted access`)
125 * `XMLRPC_PORT`: XMLRPC port through nginx over SCGI socket (default `8000`)
126 * `XMLRPC_SIZE_LIMIT`: Maximum body size of XMLRPC calls (default `1M`)
127 * `RUTORRENT_AUTHBASIC_STRING`: Message displayed during validation of ruTorrent Basic Auth (default `ruTorrent restricted access`)
128 * `RUTORRENT_PORT`: ruTorrent HTTP port (default `8080`)
129 * `WEBDAV_AUTHBASIC_STRING`: Message displayed during validation of WebDAV Basic Auth (default `WebDAV restricted access`)
130 * `WEBDAV_PORT`: WebDAV port on completed downloads (default `9000`)
131  
132 ### rTorrent
133  
134 * `RT_LOG_LEVEL`: rTorrent log level (default `info`)
135 * `RT_LOG_EXECUTE`: Log executed commands to `/data/rtorrent/log/execute.log` (default `false`)
136 * `RT_LOG_XMLRPC`: Log XMLRPC queries to `/data/rtorrent/log/xmlrpc.log` (default `false`)
137 * `RT_SESSION_SAVE_SECONDS`: Seconds between writing torrent information to disk (default `3600`)
138 * `RT_TRACKER_DELAY_SCRAPE`: Delay tracker announces at startup (default `true`)
139 * `RT_DHT_PORT`: DHT UDP port (`dht.port.set`, default `6881`)
140 * `RT_INC_PORT`: Incoming connections (`network.port_range.set`, default `50000`)
141 * `RT_SEND_BUFFER_SIZE`: Sets default tcp wmem value (`network.send_buffer.size.set`, default `4M`)
142 * `RT_RECEIVE_BUFFER_SIZE`: Sets default tcp rmem value (`network.receive_buffer.size.set`, default `4M`)
143 * `RT_PREALLOCATE_TYPE`: Sets the type of [disk space preallocation](#rtorrent-disk-space-preallocation) (default `0`)
144  
145 ### ruTorrent
146  
147 * `RU_REMOVE_CORE_PLUGINS`: Comma separated list of core plugins to remove ; set to `false` to disable removal
148 * `RU_HTTP_USER_AGENT`: ruTorrent HTTP user agent (default `Mozilla/5.0 (Windows NT 6.0; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0`)
149 * `RU_HTTP_TIME_OUT`: ruTorrent HTTP timeout in seconds (default `30`)
150 * `RU_HTTP_USE_GZIP`: Use HTTP Gzip compression (default `true`)
151 * `RU_RPC_TIME_OUT`: ruTorrent RPC timeout in seconds (default `5`)
152 * `RU_LOG_RPC_CALLS`: Log ruTorrent RPC calls (default `false`)
153 * `RU_LOG_RPC_FAULTS`: Log ruTorrent RPC faults (default `true`)
154 * `RU_PHP_USE_GZIP`: Use PHP Gzip compression (default `false`)
155 * `RU_PHP_GZIP_LEVEL`: PHP Gzip compression level (default `2`)
156 * `RU_SCHEDULE_RAND`: Rand for schedulers start, +0..X seconds (default `10`)
157 * `RU_LOG_FILE`: ruTorrent log file path for errors messages (default `/data/rutorrent/rutorrent.log`)
158 * `RU_DO_DIAGNOSTIC`: ruTorrent diagnostics like permission checking (default `true`)
159 * `RU_CACHED_PLUGIN_LOADING`: Set to `true` to enable rapid cached loading of ruTorrent plugins (default `false`)
160 * `RU_SAVE_UPLOADED_TORRENTS`: Save torrents files added wia ruTorrent in `/data/rutorrent/share/torrents` (default `true`)
161 * `RU_OVERWRITE_UPLOADED_TORRENTS`: Existing .torrent files will be overwritten (default `false`)
162 * `RU_FORBID_USER_SETTINGS`: If true, allows for single user style configuration, even with webauth (default `false`)
163 * `RU_LOCALE`: Set default locale for ruTorrent (default `UTF8`)
164  
165 ## Volumes
166  
167 * `/data`: rTorrent / ruTorrent config, session files, log, ...
168 * `/downloads`: Downloaded files
169 * `/passwd`: Contains htpasswd files for basic auth
170  
171 > :warning: Note that the volumes should be owned by the user/group with the specified `PUID` and `PGID`. If you don't
172 > give the volumes correct permissions, the container may not start.
173  
174 ## Ports
175  
176 * `6881` (or `RT_DHT_PORT`): DHT UDP port (`dht.port.set`)
177 * `8000` (or `XMLRPC_PORT`): XMLRPC port through nginx over SCGI socket
178 * `8080` (or `RUTORRENT_PORT`): ruTorrent HTTP port
179 * `9000` (or `WEBDAV_PORT`): WebDAV port on completed downloads
180 * `50000` (or `RT_INC_PORT`): Incoming connections (`network.port_range.set`)
181  
182 > :warning: Port p+1 defined for `XMLRPC_PORT`, `RUTORRENT_PORT` and `WEBDAV_PORT` will also be reserved for
183 > healthcheck. (e.g. if you define `RUTORRENT_PORT=8080`, port `8081` will be reserved)
184  
185 ## Usage
186  
187 ### Docker Compose
188  
189 Docker compose is the recommended way to run this image. Copy the content of
190 folder [examples/compose](examples/compose) in `/var/rtorrent-rutorrent/` on
191 your host for example. Edit the compose file with your preferences and run the
192 following command:
193  
194 ```shell
195 mkdir data downloads passwd
196 chown ${PUID}:${PGID} data downloads passwd
197 docker compose up -d
198 docker compose logs -f
199 ```
200  
201 ### Command line
202  
203 You can also use the following minimal command:
204  
205 ```shell
206 mkdir data downloads passwd
207 chown ${PUID}:${PGID} data downloads passwd
208 docker run -d --name rtorrent_rutorrent \
209 --ulimit nproc=65535 \
210 --ulimit nofile=32000:40000 \
211 -p 6881:6881/udp \
212 -p 8000:8000 \
213 -p 8080:8080 \
214 -p 9000:9000 \
215 -p 50000:50000 \
216 -v $(pwd)/data:/data \
217 -v $(pwd)/downloads:/downloads \
218 -v $(pwd)/passwd:/passwd \
219 crazymax/rtorrent-rutorrent:latest
220 ```
221  
222 ## Notes
223  
224 ### XMLRPC through nginx
225  
226 rTorrent 0.9.7+ has a built-in daemon mode disabling the user interface, so you
227 can only control it via XMLRPC. Nginx will route XMLRPC requests to rtorrent
228 through port `8000`. These requests can be secured with basic authentication
229 through the `/passwd/rpc.htpasswd` file in which you will need to add a username
230 with his password. See below to populate this file with a user / password.
231  
232 ### WebDAV
233  
234 WebDAV allows you to retrieve your completed torrent files in `/downloads/complete`
235 on port `9000`. Like XMLRPC, these requests can be secured with basic authentication
236 through the `/passwd/webdav.htpasswd` file in which you will need to add a
237 username with his password. See below to populate this file with a user / password.
238  
239 ### Populate .htpasswd files
240  
241 For ruTorrent basic auth, XMLRPC through nginx and WebDAV on completed downloads,
242 you can populate `.htpasswd` files with the following command:
243  
244 ```
245 docker run --rm -it httpd:2.4-alpine htpasswd -Bbn <username> <password> >> $(pwd)/passwd/webdav.htpasswd
246 ```
247  
248 Htpasswd files used:
249  
250 * `rpc.htpasswd`: XMLRPC through nginx
251 * `rutorrent.htpasswd`: ruTorrent basic auth
252 * `webdav.htpasswd`: WebDAV on completed downloads
253  
254 ### Bootstrap config `.rtlocal.rc`
255  
256 When rTorrent is started the bootstrap config [/etc/rtorrent/.rtlocal.rc](rootfs/tpls/etc/rtorrent/.rtlocal.rc)
257 is imported. This configuration cannot be changed unless you rebuild the image
258 or overwrite these elements in your `.rtorrent.rc`. Here are the particular
259 properties of this file:
260  
261 * `system.daemon.set = true`: Launcher rTorrent as a daemon
262 * A config layout for the rTorrent's instance you can use in your `.rtorrent.rc`:
263 * `cfg.basedir`: Home directory of rtorrent (`/data/rtorrent/`)
264 * `cfg.download`: Download directory (`/downloads/`)
265 * `cfg.download_complete`: Completed downloads (`/downloads/complete/`)
266 * `cfg.download_temp`: Downloads in progress (`/downloads/temp/`)
267 * `cfg.logs`: Logs directory (`/data/rtorrent/log/`)
268 * `cfg.session`: Session directory (`/data/rtorrent/.session/`)
269 * `cfg.watch`: Watch directory for torrents (`/data/rtorrent/watch/`)
270 * `cfg.rundir`: Runtime data of rtorrent (`/var/run/rtorrent/`)
271 * `d.data_path`: Config var to get the full path of data of a torrent (workaround for the possibly empty `d.base_path` attribute)
272 * `directory.default.set`: Default directory to save the downloaded torrents (`cfg.download_temp`)
273 * `session.path.set`: Default session directory (`cfg.session`)
274 * PID file to `/var/run/rtorrent/rtorrent.pid`
275 * `network.scgi.open_local`: SCGI local socket and make it group-writable and secure
276 * `network.port_range.set`: Listening port for incoming peer traffic (`50000-50000`)
277 * `dht.port.set`: UDP port to use for DHT (`6881`)
278 * `log.open_file`: Default logging to `/data/rtorrent/log/rtorrent.log`
279 * Log level can be modified with the environment variable `RT_LOG_LEVEL`
280 * `rpc_events` are logged be default
281 * To log executed commands, add the environment variable `RT_LOG_EXECUTE`
282 * To log XMLRPC queries, add the environment variable `RT_LOG_XMLRPC`
283  
284 ### Override or add a ruTorrent plugin/theme
285  
286 You can add a plugin for ruTorrent in `/data/rutorrent/plugins/`. If you add a
287 plugin that already exists in ruTorrent, it will be removed from ruTorrent core
288 plugins and yours will be used. And you can also add a theme in `/data/rutorrent/themes/`.
289 The same principle as for plugins will be used if you want to override one.
290  
291 > :warning: Container has to be restarted to propagate changes
292  
293 ### Edit a ruTorrent plugin configuration
294  
295 As you probably know, plugin configuration is not outsourced in ruTorrent.
296 Loading the configuration of a plugin is done via a `conf.php` file placed at
297 the root of the plugin folder. To solve this issue with Docker, a special folder
298 has been created in `/data/rutorrent/plugins-conf` to allow you to configure
299 plugins. For example to configure the `diskspace` plugin, you will need to create
300 the `/data/rutorrent/plugins-conf/diskspace.php` file with your configuration:
301  
302 ```php
303 <?php
304  
305 $diskUpdateInterval = 10; // in seconds
306 $notifySpaceLimit = 512; // in Mb
307 $partitionDirectory = null; // if null, then we will check rtorrent download directory (or $topDirectory if rtorrent is unavailable)
308 // otherwise, set this to the absolute path for checked partition.
309 ```
310  
311 > :warning: Container has to be restarted to propagate changes
312  
313 ### Increase Docker timeout to allow rTorrent to shutdown gracefully
314  
315 After issuing a shutdown command, Docker waits 10 seconds for the container to
316 exit before it is killed. If you are a seeding many torrents, rTorrent may be
317 unable to gracefully close within that time period. As a result, rTorrent is
318 closed forcefully and the lockfile isn't removed. This stale lockfile will
319 prevent rTorrent from restarting until the lockfile is removed manually.
320  
321 The timeout period can be extended by either adding the parameter `-t XX` to
322 the docker command or `stop_grace_period: XXs` in `compose.yml`, where
323 `XX` is the number of seconds to wait for a graceful shutdown.
324  
325 ### WAN IP address
326  
327 `WAN_IP` is the public IP address sent to the tracker. In the majority of cases
328 you don't need to set it as it will be automatically determined by the tracker.
329  
330 But it can be sometimes required to enforce the public IP address when you
331 are behind a VPN where an erroneous IP is sometimes reported.
332  
333 You can also use the `WAN_IP_CMD` environment variable to specify a command to
334 resolve your public IP address. Here are some commands you can use:
335  
336 * `dig +short myip.opendns.com @resolver1.opendns.com`
337 * `curl -s ifconfig.me`
338 * `curl -s ident.me`
339  
340 ### Configure rTorrent session saving
341  
342 `RT_SESSION_SAVE_SECONDS` is the seconds between writing torrent information to
343 disk. The default is 3600 seconds which equals 1 hour. rTorrent has a bad
344 default of 20 minutes. Twenty minutes is bad for the lifespan of SSDs and
345 greatly reduces torrent throughput.
346  
347 It is no longer possible to lose torrents added through ruTorrent on this
348 docker container. Only torrent statistics are lost during a crash. (Ratio,
349 Total Uploaded & Downloaded etc.)
350  
351 Higher values will reduce disk usage, at the cost of minor stat loss during a
352 crash. Consider increasing to 10800 seconds (3 hours) if running thousands of
353 torrents.
354  
355 ### rTorrent tracker scrape patch
356  
357 `RT_TRACKER_DELAY_SCRAPE` specifies whether to delay tracker announces at
358 rTorrent startup. The default value is `true`. There are two main benefits to
359 keeping this feature enabled:
360  
361 1) Software Stability: rTorrent will not crash or time-out with tens of thousands of trackers.
362 2) Immediate Access: ruTorrent can be accessed immediately after rTorrent is started.
363  
364 ### rTorrent send receive buffers
365  
366 Overriding the default TCP rmem and wmem values for rTorrent improves torrent
367 throughput.
368  
369 * `RT_SEND_BUFFER_SIZE`: Sets default tcp wmem value for the socket.
370 * `RT_RECEIVE_BUFFER_SIZE`: Sets default tcp rmem value for the socket.
371  
372 Recommended values:
373 * `2GB of less system memory`: Reduce to 1M send and 1M receive regardless of speed.
374 * `4GB to 16GB of system memory`: Keep at default values of 4M send and 4M receive.
375 * `16GB to 32GB of system memory`: Increase to 8M send for 500Mbps speeds.
376 * `32GB to 64GB of system memory`: Increase to 16M send for 1G speeds.
377 * `64GB to 128GB of system memory`: Increase to 32M send for 2.5G speeds.
378 * `128GB to 256GB of system memory`: Increase to 64M send for 10G speeds.
379  
380 Memory is better spent elsewhere except under limited circumstances for high
381 memory and speed conditions. The default values should not be increased, unless
382 both the memory and speed requirements are met. These values of system memory
383 are also recommended based on the port speed for rTorrent to reduce disk usage.
384  
385 ### rTorrent disk space preallocation
386  
387 Preallocate disk space for contents of a torrent
388  
389 * `RT_PREALLOCATE_TYPE`: Sets the type of disk space preallocation to use.
390  
391 Acceptable values:
392 * `0 = disabled (default value)`
393 * `1 = enabled, allocate when a file is opened for write`
394 * `2 = enabled, allocate space for the whole torrent at once`
395  
396 This feature is disabled by default becuase it only benefits HDDs.
397 By allocating files in sequence we can increase the read speed for seeding.
398  
399 The first type "1" only allocates disk space for files which start downloading.
400 Use where disk space is more important than speed. Or you intend to download selective torrent files.
401  
402 The second type "2" allocates disk space for the entire torrent, whether it's downloaded or not.
403 This method is faster than "1" becuase it reduces random reads for the entire torrent.
404 Use where speed is more important than disk space. Or you intend to download 100% of every torrent.
405  
406 ## Upgrade
407  
408 To upgrade, pull the newer image and launch the container:
409  
410 ```shell
411 docker compose pull
412 docker compose up -d
413 ```
414  
415 ## Contributing
416  
417 Want to contribute? Awesome! The most basic way to show your support is to star
418 the project, or to raise issues. You can also support this project by [**becoming a sponsor on GitHub**](https://github.com/sponsors/crazy-max)
419 or by making a [PayPal donation](https://www.paypal.me/crazyws) to ensure this
420 journey continues indefinitely!
421  
422 Thanks again for your support, it is much appreciated! :pray:
423  
424 ## License
425  
426 MIT. See `LICENSE` for more details.