Plex+Docker+Synology=❤

This post is either a cool idea or ridiculous. Having received a Synology DS220+ NAS over the winter, I decided to dive in to see how much stuff I could run on the system. Previously I used an old Ubuntu PC as a storage/print server, Plex server, and other various things. The system filled my needs as a home server for several years, but eventually, I ran out of storage space and needed to decide on the next stage of my home sever life.

All of this got me thinking about Docker. It’s not a technology I got to use a work, but software containerization is something I felt I’ll need to be familiar with going forward. With that decided, I dove into learning Docker and rolling out Plex on the Synology.

Setup

Step 1: Install Docker

No surprise here. The first step of using Docker on Synology is to install it. The process is super easy because the software is available in the Package Center. Just search for Docker and click Install. A new shared folder will be created called Docker. I use this folder to store the persistent data kept for containers.

Install Docker onto Synology NAS

Step 2: Disable SSDP

I wrote about this back in February 2022 but will summarize it here. Out of the box, the file services built into Synology’s system uses port 1900, so Windows devices can use network discovery to find the NAS in web browsers. Plex also uses port 1900 for DLNA discovery. You can’t have both services bound to port 1900. I don’t plan to use the Windows network discovery feature, so I disabled the service. The setting is found under Control Panel > File Services > Advanced > SSDP.

Disable SSDP on Synology

Step 3: Create Folders for the Plex Docker Container

At least three folders are needed for Plex, so the service’s data is persistent between container updates.

  1. config: This contains all the configuration, metadata, logs, and cache data for the Plex service.
    1. Create the folder in the Docker shared folder.
  2. transcode: When Plex transcodes video for playback, the data is temporarily stored in this folder before being served to the client.
    1. Create the folder in the Docker shared folder.
  3. Media: This contains all the movies, TV shows, music, games, etc., that Plex will serve.
    1. I recommend creating a new shared folder in Synology’s Control Panel for these files.
The folders Plex needs access to

Step 4 (Option 1): Setup the Plex Docker Container using the GUI

There are several ways to set up Plex inside Docker on a Synology NAS. The GUI built into Synology is good for someone starting with Docker and can get you 99% to a complete setup. If you need hardware transcoding, check out option 2 below.

  1. Open Docker from the Main Menu.
  2. Go to the Registry and search for Plex.
  3. Download plexinc/pms-docker .
  4. Go to the Image section. Select plexinc/pms-docker and click Launch. This will start the container creation wizard.
  5. Name the container whatever you like. Click the Advanced Settings button.
  6. In the Advanced Setting windows, configure the following sections.
    1. Volume:
      1. Add the three folders from Step 3.
        1. Config
          1. Folder: docker/plex/config
          1. Mount path: /config
        1. Transcode
          1. Folder: docker/plex/transcode
          1. Mount path: /transcode
        1. Media
          1. Folder: Media
          1. Mount path: /PlexMedia
    1. Port Settings
      1. Change all Local Port values from Auto to the same value as the Container Port.
    1. Environment
      1. Add the following variables.
        1. TZ: Use the timezone value for your location. Use https://www.php.net/manual/en/timezones.php for reference
          1. Example: America/New_York
        1. ADVERTISE_IP: http://<IP address of Synology system>:32400
          1. Example: http://192.168.1.2:32400
  7. Click Apply and Done to complete the wizard and start the container.

Step 4 (Option 2): Setup the Plex Docker Container using the CLI

Docker has more options available than what Synology makes available in the GUI. A Plex Pass subscription offers the feature of using hardware transcoding. This allows the server to use CPU/GPU transcoding instead of relying on software transcoding. The benefit is speed and the ability to stream multiple videos to clients simultaneously. However, there is a catch. The docker container running Plex needs access to the hardware, which is granted by using the –device flag. Unfortunately, there is no way to add the –device flag to Docker containers through the Synology GUI. Instead, the container must be built using the Synology NAS command-line interface.

  1. Enable SSH.
    1. Control Panel > Terminal & SNMP
    2. Enable SSH service.
  2. Use Putty or another terminal client to connect to the Synology NAS.
  3. Change the permissions to /dev/dri so the Plex docker container can access the hardware transcoder.
    1. sudo chmod a+wr /dev/dri/*
  4. Download the latest plex image from the docker hub.
    1. sudo docker pull plexinc/pms-docker
  5. Configure the docker container to run Plex. Change the timezone to what matches your region (https://www.php.net/manual/en/timezones.php) and the advertised IP to that of the Synology NAS.
    sudo docker run -d \
    --name plex-docker \
    -p 32400:32400/tcp \
    -p 3005:3005/tcp \
    -p 8324:8324/tcp \
    -p 32469:32469/tcp \
    -p 1900:1900/udp \
    -p 32410:32410/udp \
    -p 32412:32412/udp \
    -p 32413:32413/udp \
    -p 32414:32414/udp \
    -e TZ="America/New_York" \
    -e ADVERTISE_IP="http://192.168.1.2:32400/" \
    -h PlexDocker \
    -v /volume1/docker/plex/db:/config \
    -v /volume1/docker/plex/transcode:/transcode \
    -v /volume1/Media:/shares/Media	 \
    --device=/dev/dri:/dev/dri \
    plexinc/pms-docker

Step 5: Final Setup

The final step is to set up your new Plex server. Open a web browser and go to http://SYNOLGY_IP_ADDRESS:32400/web . Log into your Plex account and start the setup process of the server. You can then add libraries for your music, movies, TV shows, and more.

Plex Maintenance

Plex is now running inside a Docker container on a Synology NAS. Great. How do you keep it up to date? That is the most nerve-racking part of using containers. The software inside the container isn’t updated. Instead, you delete the container, download the latest version of the software image, and build a new container using the same configuration you used during the initial setup. If all the essential files/settings/configs were saved in persistent storage, everything should work with no issues. Below are two methods for updating Docker containers on a Synology NAS depending on how the original container was set up.

Upgrade Method 1: GUI

  1. Open Docker from the Main Menu.
  2. Go to the Registry and search for Plex.
  3. Download plexinc/pms-docker. This will refresh the image.
  4. Go to the Container section.
  5. Select the Plex container and choose STOP under the Action menu.
  6. Open the Action menu again and select Reset. This will rebuild the container with the latest image.
  7. Once the container has been reset, open the Action menu and choose Start.

Upgrade Method 2: CLI

  1. Download the latest version of the Plex Docker Image.
    1. sudo docker pull plexinc/pms-docker
  2. Stop and delete the current Plex container.
    1. sudo docker stop plex-docker
    1. sudo docker rm plex-docker
  3. Create a new container using the exact same command from Step4 (Option 2) above.

Conclusion

And that’s all there is to it. Overall, I’m pleased with the results. No, the DS220+ doesn’t have as much CPU power as my old Ubuntu Server. And no, the NAS isn’t as open and easy to tinker with either. But this experiment was a way to learn something new and refresh the storage options used at home. In the future, I hope to share my experiences with other containerized applications running on the Synology (teaser: NextCloud).

Have fun.
-Tony