Installing qBittorrent on Docker and configuring shared access to downloads via SMB


create the /etc/docker/qbittorrent/Dockerfile file

FROM oraclelinux:8.6

RUN \
dnf install -y epel-release && \
dnf install -y openssl qbittorrent-nox samba supervisor && \
groupadd -g 99999 qbittorrent && \
useradd -m -u 99999 -g 99999 qbittorrent && \
mkdir -p /home/qbittorrent/{.cache,.config/qBittorrent,.local,downloads,torrents} && \
openssl req -x509 -newkey rsa:4096 -days 365 -subj "/CN=qbittorrent.domain.lan" \
  -keyout /home/qbittorrent/.config/qBittorrent/private.key \
  -out /home/qbittorrent/.config/qBittorrent/public.cer -nodes && \
chown -R qbittorrent:qbittorrent /home/qbittorrent/{.cache,.config,.local,downloads,torrents}

COPY --chown=qbittorrent:qbittorrent qBittorrent.conf /home/qbittorrent/.config/qBittorrent/
COPY smb.conf /etc/samba/smb.conf
COPY supervisor.ini /etc/supervisord.d/

ENTRYPOINT /usr/bin/supervisord -n

create the /etc/docker/qbittorrent/qBittorrent.conf file

[LegalNotice]
Accepted=true

[Preferences]
WebUI\Port=8888
WebUI\HTTPS\Enabled=true
WebUI\HTTPS\CertificatePath=/home/qbittorrent/.config/qBittorrent/public.cer
WebUI\HTTPS\KeyPath=/home/qbittorrent/.config/qBittorrent/private.key
Downloads\SavePath=/home/qbittorrent/downloads/
Downloads\TorrentExportDir=/home/qbittorrent/torrents/

create the /etc/docker/qbittorrent/smb.conf file

[global]
security = user
server role = standalone
server min protocol = SMB2
server max protocol = SMB3
passdb backend = tdbsam:/etc/samba/passdb.tdb
log level = 1

[downloads]
path=/home/qbittorrent/downloads
guest ok = no
writable = yes
browsable = yes
create mask = 0700
directory mask = 0700

[torrents]
path=/home/qbittorrent/torrents
guest ok = no
writable = yes
browsable = yes
create mask = 0700
directory mask = 0700

create the /etc/docker/qbittorrent/supervisor.ini file

[program:qbittorrent]
command=/usr/bin/qbittorrent-nox
user=qbittorrent
environment=HOME="/home/qbittorrent",USER="qbittorrent"
autostart=true
autorestart=true
stdout_logfile=/var/log/qbittorrent.out
stderr_logfile=/var/log/qbittorrent.err

[program:samba]
command=/usr/sbin/smbd --foreground --no-process-group
autostart=true
autorestart=true
stdout_logfile=/var/log/samba.out
stderr_logfile=/var/log/samba.err

create the /etc/docker/qbittorrent/docker-compose.yml file

version: '3.8'

networks:
  net:
    ipam:
      config:
        - subnet: 192.168.100.0/24

volumes:
  cache:
  config:
  local:
  downloads:
  torrents:
  samba:
  supervisor:

services:
  qbittorrent:
    container_name: qbittorrent
    build:
      context: .
    volumes:
      - cache:/home/qbittorrent/.cache
      - config:/home/qbittorrent/.config
      - local:/home/qbittorrent/.local
      - downloads:/home/qbittorrent/downloads
      - torrents:/home/qbittorrent/torrents
      - samba:/etc/samba
      - supervisor:/etc/supervisor
    networks:
      net:
    ports:
      - 8888:8888
      - 445:445

start the container

docker-compose -f /etc/docker/qbittorrent/docker-compose.yml up -d

change SMB user password

docker exec --user root -t -i qbittorrent smbpasswd -a qbittorrent

Leave a Reply