How to Run Plex via LinuxServer.io’s Docker Image

Late last year, I bought a Blu-ray/DVD drive for my home computer and ripped all the movies and television shows I have on physical disks. The files are now stored on the NAS running in my local network. I can watch that media on just about any device in my house using Plex, a wonderful piece of software for streaming media around the network.

Today I’ll explain how I set up my system to run Plex’s software via the LinuxServer.io Plex image on a Docker host in my basement.

Want to learn more about my home network? Last time I wrote about running a Unifi Controller image.

About LinuxServer.io

LinuxServer.io describes their organization as:

A group of like-minded enthusiasts from across the world who build and maintain the largest collection of Docker images on the web. At our core are the principles behind Free and Open Source Software. Our primary goal is to provide easy-to-use and streamlined Docker images with clear and concise documentation.

I’ve been using LinuxServer.io images for a couple of years; they are certainly easy-to-use, clear, and concisely documented. I tend to check here first when I need a new image.

Plex Container Configuration

I tend to use docker-compose to build and run my images and containers. Here are the contents of the docker-compose.yml for this project:


---
version: "3.7"
services:
  plex:
    container_name: plex
    image: linuxserver/plex:1.20.1.3252-a78fef9a9-ls116
    network_mode: bridge
    restart: unless-stopped

    devices:
      - /dev/dri:/dev/dri
    environment:
      - PUID=XYZ # user account id on the system
      - PGID=ABC # group id on the system
      - TZ=America/Detroit
      - UMASK_SET=022
      - VERSION=docker
    ports:
      # Port listing from Plex website as of 2019-08-18.
      # https://support.plex.tv/articles/201543147-what-network-ports-do-i-need-to-allow-through-my-firewall/
      # Disabled 1900 and 5353 as of 2019-08-18.
      # Was running into some sort of conflict when trying to map them with bridge mode.
      # Something else on the NAS is using those ports -- home assistant perhaps?
      # The ports are for Plex services I don't necessarily need, so they are disabled for now.
      # - "1900:1900/udp" # (for access to the Plex DLNA Server)
      # - "5353:5353/udp" # (for older Bonjour/Avahi network discovery)

      - "32400:32400" # (for access to the Plex Media Server) [required]
      - "3005:3005" # (for controlling Plex Home Theater via Plex Companion)
      - "8324:8324" # (for controlling Plex for Roku via Plex Companion)
      - "32410:32410/udp" # (for current GDM network discovery)
      - "32412:32412/udp" # (for current GDM network discovery)
      - "32413:32413/udp" # (for current GDM network discovery)
      - "32414:32414/udp" # (for current GDM network discovery)
      - "32469:32469" # (for access to the Plex DLNA Server)
    volumes:
      - /volume1/docker/plex/config:/config
      - /volume1/docker/plex/transcode:/transcode # this is not strictly necessary, but I've configured Plex to use this directory for transcoding. Should make it easier to backup only the configuration and not transcoding artifacts.
      - /volume1/Media/Movies:/data/Movies:ro
      - /volume1/Media/Television:/data/Television:ro

Much of this is derived from the instructions in the image’s README file:
image: linuxserver/plex:1.20.1.3252-a78fef9a9-ls116

Let’s step through some of the interesting bits.

Version

My personal preference is to lock images down to a specific version, if at all feasible. This way I won’t be surprised when, say, a new version of an image requires or breaks the current configuration. LinuxServer is great about providing versioned images over time.

Personally, I rarely update the Plex image. I don’t use it that often, so new features are not particularly compelling to me.

Devices

  devices:
    - /dev/dri:/dev/dri

Here I make the Intel QuickSync device available to the container. It’s used for hardware transcoding. The README’s Hardware Acceleration section has more information.

Environment

environment:
  - PUID=XYZ # user account id on the system
  - PGID=ABC # group id group on the system
  - TZ=America/Detroit

LinuxServer has a great system for setting user and group permissions. In this case, I have PUID and PGID set to the user and group number on my host system. (I have the comment there so that, when I look at this file again three months later, I can remember why I have some hardcoded numbers typed into the file.)

Services

services:
  plex:
    network_mode: bridge

ports:
  # Port listing from Plex website as of 2019-08-18.
  # https://support.plex.tv/articles/201543147-what-network-ports-do-i-need-to-allow-through-my-firewall/
  # Disabled 1900 and 5353 as of 2019-08-18.
  # Was running into some sort of conflict when trying to map them with bridge mode.
  # Something else on the NAS is using those ports -- home assistant perhaps?
  # The ports are for Plex services I don't necessarily need, so they are disabled for now.
  # - "1900:1900/udp" # (for access to the Plex DLNA Server)
  # - "5353:5353/udp" # (for older Bonjour/Avahi network discovery)

  - "32400:32400" # (for access to the Plex Media Server) [required]
  - "3005:3005" # (for controlling Plex Home Theater via Plex Companion)
  - "8324:8324" # (for controlling Plex for Roku via Plex Companion)
  - "32410:32410/udp" # (for current GDM network discovery)
  - "32412:32412/udp" # (for current GDM network discovery)
  - "32413:32413/udp" # (for current GDM network discovery)
  - "32414:32414/udp" # (for current GDM network discovery)
  - "32469:32469" # (for access to the Plex DLNA Server)

These ports are recommended by the image’s README file. The README and comments document what all of them are for. In my case, I’m running in bridge more, and two of the port mappings are commented out because they were conflicting with something else on my system. I avoided the problem by not using those mappings, and everything is working well enough in my home. Your mileage may vary. Check the README for more information.

Volumes

volumes:
  - /volume1/docker/plex/config:/config
  - /volume1/docker/plex/transcode:/transcode # this is not strictly necessary, but I've configured Plex to use this directory for transcoding. Should make it easier to backup only the configuration and not transcoding artifacts.
  - /volume1/Media/Movies:/data/Movies:ro
  - /volume1/Media/Television:/data/Television:ro

Last are my volume mappings. Two things of note:

  • I map the two Media directories read-only to provide a little extra protection if something goes wrong.
  • I have the transcode directory mapped separately from the config directory so that it’s easier to back up one without the other.

Getting a Little Trickier

This configuration is a smidge more sophisticated than the Unifi Controller configuration I wrote about last time. It’s got a device mapping, a different kind of networking, and some trial-and-error port configuration. But it’s hopefully still not too bad. I look forward to future posts with even more sophisticated setups.