Setup Bazarr in Docker to automate & manage your Plex Media Subtitles

Guides Jan 14, 2022
Bazarr is a companion application to Sonarr and Radarr that manages and downloads subtitles based on your requirements.

We'll be installing Bazarr in Docker. For other platforms, take a look at Bazarr's official documentation here.

ℹ️
For help in setting up Docker on your server, check out my docker guide here.

Since Bazarr doesn't have any official docker image, we'll be using LinuxServer's Bazarr Docker image.

Supported Architectures

Their images support multiple architectures such as x86-64, arm64 and armhf. We utilize the docker manifest for multi-platform awareness. More information is available from docker here and their announcement here.

Simply pulling lscr.io/linuxserver/bazarr should retrieve the correct image for your arch, but you can also pull specific arch images via tags.

The architectures supported by this image are:

Architecture Tag
x86-64 amd64-latest
arm64 arm64v8-latest
armhf arm32v7-latest

Version Tags

This image provides various versions that are available via tags. latest tag usually provides the latest stable version. Others are considered under development and caution must be exercised when using them.

Tag Description
latest Stable releases from Bazarr
development Pre-releases from Bazarr

Installation

To help you get started creating a container from this image you can either use the docker CLI or docker-compose.

docker CLI

docker run -d \
  --name=bazarr \
  -e PUID=1000 \
  -e PGID=1000 \
  -e TZ=Europe/London \
  -p 6767:6767 \
  -v /path/to/bazarr/config:/config \
  -v /path/to/movies:/movies `#optional` \
  -v /path/to/tv:/tv `#optional` \
  --restart unless-stopped \
  lscr.io/linuxserver/bazarr

Go down to the parameters section for more info.

docker-compose

---
version: "2.1"
services:
  bazarr:
    image: lscr.io/linuxserver/bazarr
    container_name: bazarr
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
    volumes:
      - /path/to/bazarr/config:/config
      - /path/to/movies:/movies #optional
      - /path/to/tv:/tv #optional
    ports:
      - 6767:6767
    restart: unless-stopped

Parameters

Docker images are configured using parameters passed at runtime (such as those above). These parameters are separated by a colon and indicate <external>:<internal> respectively. For example, -p 8080:80 would expose port 80 from inside the container to be accessible from the host's IP on port 8080 outside the container.

Ports (-p)

Parameter Function
6767 The port for the Bazarr webinterface

Environment Variables (-e)

Env Function
PUID=1000 for UserID - see below for explanation
PGID=1000 for GroupID - see below for explanation
TZ=Europe/London Specify a timezone to use EG Europe/London. See here for your timezone code.

Volume Mappings (-v)

Volume Function
/config Bazarr data
/movies Location of your movies. I recommend mounting your movies folder to the same path in this container as you have in radarr's container, or else you can setup path mapping in bazarr's settings.
/tv Location of your TV Shows. I recommend mounting your tv shows folder to the same path in this container as you have in sonarr's container, or else you can setup path mapping in bazarr's settings.

Other parameters

  • To use host network mode, simply add network_mode: "host" to docker-compose or --net=host to docker-CLI.
  • If you are managing docker containers via systemd like me (see below), set the restart policy to no.
  • To limit CPU threads for this container, add cpus: value to docker-compose or --cpus=value to docker-CLI. Here value is the number of cpu threads. For instance, if the host machine has four CPU threads and you set --cpus="1.5", the container is guaranteed at most one and a half of the CPU threads.

After this, you can access the WebUI at <your-ip>:6767, for more information check out Bazarr.

Umask for running applications

For all of their images, they provide the ability to override the default umask settings for services started within the containers using the optional -e UMASK=022 setting. Keep in mind umask is not chmod it subtracts from permissions based on its value it does not add. Please read up here before asking for support.

User / Group Identifiers

When using volumes (-v flags), permissions issues can arise between the host OS and the container, we avoid this issue by allowing you to specify the user PUID and group PGID.

Ensure any volume directories on the host are owned by the same user you specify and any permissions issues will vanish like magic.

In this instance PUID=1000 and PGID=1000, to find your use id user as below:

  $ id username
    uid=1000(dockeruser) gid=1000(dockergroup) groups=1000(dockergroup)

Docker Mods

LinuxServer publishes various Docker Mods to enable additional functionality within the containers. The list of Mods available for this image (if any), as well as universal mods that can be applied to any one of their images, can be accessed via the link below.

Bazarr Mods
Universal Mods

Important Commands

Shell access whilst the container is running:

docker exec -it bazarr /bin/bash

To monitor the logs of the container in realtime:

docker logs -f bazarr

Container version number:

docker inspect -f '{{ index .Config.Labels "build_version" }}' bazarr

Image version number:

docker inspect -f '{{ index .Config.Labels "build_version" }}' lscr.io/linuxserver/bazarr

Managing Bazarr Docker via Systemd

🖥️
You can look into Managing Docker containers via systemd section in my Docker Ubuntu Guide for detailed info.

Here's my systemd file

[Unit]
Description=Docker bazarr
After=media-drive.mount
Requires=media-drive.mount
StartLimitIntervalSec=10
StartLimitBurst=5

[Service]
Type=simple
ExecStart=/usr/bin/docker start -a bazarr
ExecStop=/usr/bin/docker stop bazarr
Restart=always
RestartSec=60s

[Install]
WantedBy=media-drive.mount

Note: I start all my docker containers after I have mounted my external hard drive, therefore the media-drive.mount is for that.

For a more generic systemd service,

[Unit]
Description=Docker bazarr
After=network-online.target
Requires=network-online.target
StartLimitIntervalSec=10
StartLimitBurst=5

[Service]
Type=simple
ExecStart=/usr/bin/docker start -a bazarr
ExecStop=/usr/bin/docker stop bazarr
Restart=always
RestartSec=60s

[Install]
WantedBy=multi-user.target

Now to start, stop, or restart the bazarr docker container, you would just use,

sudo systemctl start bazarr.service
sudo systemctl stop bazarr.service
sudo systemctl restart bazarr.service

Note: If you are managing docker containers via systemd like this, DONT use docker restart policies and docker start/stop commands separately. If you stop a container directly via the docker stop command, this systemd service will just restart it after a 60s interval. Also, be sure to set a restart=no flag for your container.

Configuration

For detailed instructions on configuring Bazarr, take a look at Bazarr's official documentation here.

Some Key Points from my configuration

  • I have set up 3 separate bazarr instances on my server. one for 1080p, one for 4K, and another for Dolby Vision.
  • All 3 of them are just different docker containers with the same images but different bazarr config folders.
  • To give more resources to my Plex server and other services, I have limited Bazarr containers to 2 out of 4 CPU threads that I have.
  • Also, I am running these containers in host network mode and have changed their ports from Bazarr's settings and I am managing them via systemd instead of docker restart policies.

My Configured Subtitle Providers

Sonarr Configuration

  • Enter your Sonarr's IP address and port.
  • For the minimum score, I chose 90. You can of course test out various scores to suit your need.
  • In the Path Mapping section, map the Sonarr's media path to your Bazarr's corresponding path mount. For example, if your media on the Sonarr docker container is at "/media/tvshows" and that directory is mounted at "/tv" in your Bazarr docker container, then you would map "/media/tvshows" to "/tv".

Radarr Configuration

  • Enter your Radarr's IP address and port.
  • For the minimum score, I chose 80. You can of course test out various scores to suit your need.
  • In the Path Mapping section, map the Radarr's media path to your Bazarr's corresponding path mount. For example, if your media on the Radarr docker container is at "/media/movies" and that directory is mounted at "/movies" in your Bazarr docker container, then you would map "/media/movies" to "/movies".

That's it.

This should help you set up and configure Bazarr for the most part.

For any doubts, feel free to comment below.

References

  1. Bazarr Website.
  2. Bazarr Official Docs.
  3. LinuxServer Docs.

Tags