Improve Docker build

* Improves code readability.
* Improve documentation.
* Fix "docker stop" doesn't terminate qbt gracefully which could lead to
  data corruption.
* Provide correct/working bittorrent listening port by default.
* Make use of qbt profile option instead of hacking environment
  variables.
* Simplify build steps.

PR #16976.
This commit is contained in:
Chocobo1
2022-05-05 11:02:57 +08:00
committed by GitHub
parent fb7f7d0c75
commit 4894578b72
3 changed files with 110 additions and 86 deletions

107
dist/docker/Readme.md vendored
View File

@@ -1,68 +1,71 @@
# Docker Container Name
# qBittorrent-nox Docker Image
This Dockerfile allows you to build a qBittorrent-nox container
This Dockerfile allows you to build a docker image containing qBittorrent-nox
## Getting Started
## Prerequisities
### Prerequisities
In order to build/run this image you'll need docker installed: https://docs.docker.com/get-docker/
## Building docker image
In order to run this container you'll need docker installed.
* [Windows](https://docs.docker.com/windows/started)
* [OS X](https://docs.docker.com/mac/started/)
* [Linux](https://docs.docker.com/linux/started/)
## Built
in the docker folder run
In this docker folder run:
```shell
release="4.2.0" ; sudo docker build --build-arg BUILD_TYPE=Release --build-arg RELEASE=$release -t qbittorrent-nox:$release --rm .
export \
QBT_VERSION=devel
docker build \
--build-arg QBT_VERSION \
-t qbittorrent-nox:"$QBT_VERSION" \
.
```
where:
### Parameters
* the `release` variable is the specific tagged version you want to build
* the `BUILD_TYPE` argument is the build you want to create `Debug` or `Release`
* the `RELEASE` argument works as the but is the actual argument given to docker, in the above script is defined by the `release` variable
* `QBT_VERSION`
This environment variable specifies the version of qBittorrent-nox to be built. \
For example, `4.4.0` is a valid entry. You can find all tagged versions [here](https://github.com/qbittorrent/qBittorrent/tags). \
Or you can put `devel` to build the latest development version.
## Running docker image
### Usage
* To start the the docker image simply run:
```shell
export \
QBT_VERSION=devel \
QBT_EULA=accept \
QBT_WEBUI_PORT=8080
docker run \
-it \
--rm \
--name qbittorrent-nox \
-e QBT_EULA \
-e QBT_WEBUI_PORT \
-p "$QBT_WEBUI_PORT":"$QBT_WEBUI_PORT" \
-p 6881:6881/tcp \
-p 6881:6881/udp \
-v /your_path/config:/config \
-v /your_path/downloads:/downloads \
qbittorrent-nox:"$QBT_VERSION"
```
Then you can login at: `http://127.0.0.1:8080`
#### Container Variables
* To stop the container:
```shell
docker stop -t 1800 qbittorrent-nox
```
there is one important variable to run the container:
### Parameters
* the `LEGAL` varible defines if you accept the Legal Notice, put accept as a value only if you understand and accept the Legal Notice
* `QBT_VERSION` \
The same as [above](#variables).
* `QBT_EULA` \
This environment variable defines whether you accept the end-user license agreement (EULA) of qBittorrent. \
Put `accept` only if you understand and accepted the EULA. You can find
the EULA [here](https://github.com/qbittorrent/qBittorrent/blob/56667e717b82c79433ecb8a5ff6cc2d7b315d773/src/app/main.cpp#L320-L323).
* `QBT_WEBUI_PORT` \
This environment variable sets the port number which qBittorrent WebUI will be binded to.
#### Volumes
### Volumes
there are three main locations:
* `config` contains qBittorrent configurations
* `data` contains qBittorrent application data
* `downloads` contains the files downloaded by qBittorrent
```shell
docker run give.example.org/of/your/container:v0.2.1 parameters
```
#### Network
on the port `8080` the webinterface is run
#### RUN
To start the the docker image simply run
```shell
docker run --env LEGAL=accept -p 8080:8080 -v /your/path/config:/config -v /your/path/data:/data -v /your/path/download:/downloads --name qBittorrent qbittorrent-nox:4.2.0
```
to stop the container
```shell
docker stop qBittorrent
```
There are some paths involved:
* `/your_path/config` on your host machine will contain qBittorrent configurations
* `/your_path/downloads` on your host machine will contain the files downloaded by qBittorrent