Skip to content

Plex in Container Manager on a Synology NAS (Hardware Transcoding)

Last updated on 30 November 2023

Important or Recent Updates
Historic UpdatesDate
New DSM7.2 Container Manager Update 01/05/2023
Added additional security option to the compose to restrict the container from gaining new privileges as well as umask variable25/10/2023
Historic Updates

In this guide I am going to take you through the setup of Plex in Docker using Container Manager.

Plex Pass

You will only benefit from hardware transcoding if you have an active Plex Pass either monthly or lifetime. If you don’t have one you can either follow this guide or jump over to the non hardware transcoding version.

Does my Synology support Hardware Transcoding?

Before we do anything else, you need to make sure your model of Synology has hardware transcoding capabilities. You need to do a quick lookup via the linked Google Sheet below, this is updated by Plex and makes it super easy to look up your model of NAS.

If you find that hardware transcoding is not available on your model you can jump back over to the standard guide on the menu.

Let’s Begin

As usual, it’s important you complete the two proceeding guides which will get your folder structure and docker, user setup.

Folder Setup

Let’s start by getting some folders set up for the container to use. Open up File Station create the following.

Folders
/docker/projects/plex-compose
/docker/plex

Container Manager

Next we are going to set up a ‘Project’ in Container Manager. Open up Container Manager and click on Project then on the right-hand side click ‘Create’.

In the next screen we will set up our General Settings, enter the following:

SectionSetting
Project Name:plex
Path:/docker/projects/plex-compose
Source:Create docker-compose.yml

Next we are going to drop in our docker compose configuration copy all the code in the box below and paste it into line ‘1’ just like the screenshot.

YAML
services:
  plex:
    image: linuxserver/plex:latest
    container_name: plex
    network_mode: host
    environment:
      - PUID=1234 #CHANGE_TO_YOUR_UID
      - PGID=65432 #CHANGE_TO_YOUR_GID
      - TZ=Europe/London #CHANGE_TO_YOUR_TZ
      - UMASK=022
      - VERSION=latest
      - PLEX_CLAIM= #Your Plex Claim Code
    volumes:
      - /volume1/docker/plex:/config
      - /volume1/data/media:/data/media
    devices:
      - /dev/dri:/dev/dri
    security_opt:
      - no-new-privileges:true
    restart: always

A note on Network Mode

You will notice that for Plex we don’t put it on the normal bridge network, this is because DSM reserves the DLNA ports Plex requires in order to use DLNA. So we run in Host mode, so it can share the ports.

Environment Variables

We need to make some changes in order for the container to have the correct permissions to save its configuration files and to have access to your media.

VariableValue
PUID(required) The UID you obtained in the user setup guide
PGID(required) The GID you obtained in the user setup guide
TZ(required) Your timezone wikipedia.org/wiki/List_of_tz_database_time_zones
PLEX_CLAIMPlease note the PLEX_CLAIM variable is optional and not always required. You can remove this line if you don’t need it or come back and add it if you are unable to sign in to your server on start up.

To get the code go to https://plex.tv/claim and sign in, then put the code you receive after the ‘PLEX_CLAIM=’. You have 4 mins to finish the guide after doing this, so best to grab it just before running the project.

Volumes

I have pre-filled this section to pass the correct paths, the only thing that you may need to change is the /volume1/ if your file paths are on a different volume.

Click ‘Next’

You do not need to enable anything on the ‘Web portal settings’ screen click ‘Next’ again.

On the final screen click ‘Done’ which will begin the download of the container images and once downloaded they will be launched!

The image will now be downloaded and extracted. You should see ‘Code 0’ when it has finished.

You will now see your Plex running and should have a green status on the left-hand side.

Firewall Exceptions

(Skip if you don’t have the Firewall configured)

If you have enabled and configured the Synology Firewall you will need to create exceptions for any containers that have a Web UI or have any incoming or outgoing connections. This section covers the basics of how to add these. (Please note this is a generic section and will not show the specific ports used in this guide however it applies in the same way)

Also, I would like to refer people to the great guide on getting the Firewall correctly configured over on WunderTechs site.

Head into the Control Panel> Security > Firewall, from here click Edit Rules for the profile you set up when you enabled the Firewall.

Next click on Create and you will see the screen below. Source IP and Action will be automatically selected to All and Allow, I will leave it up to you as to your own preference on whether you want to lock down specific Source IPs from having access. In this example we will leave as All.

You will now choose ‘Custom‘ and then the Custom button

Now select Destination from the drop-down menu, most web based containers require TCP access but check the guide as it will show the port and protocol. Then add comma separated ports. Then press OK.

Click OK a couple of times to get back to the main screen. You will see by default the new rule is added to the bottom of the list. You must always have your Block All rule last in the list as the rules are applied top down so move your container up.

You have now completed the Firewall changes and can continue with the guide.

Plex Initial Setup

After a few minutes you should be able to access the server and go through the Plex setup by going to the IP of your NAS in your browser followed by port 32400/web/

e.g. 192.168.0.45:32400/web/

You will be asked to sign in or sign up for an account if you don’t have one already.

You should now be able to add your media which will be in the /data/media folder within Plex

Once you have got to the main Plex interface make sure you go into the settings and turn on

  • Enable HDR tone mapping
  • Use hardware acceleration when available
  • Use hardware-accelerated video encoding

That’s it you are all setup. When a new server update is available you will just need to restart the container, and it will automatically download the latest update.


Buy Me a Coffee or a Beer

If you have found my site useful please consider pinging me a tip as it helps cover the cost of running things or just lets me get the odd beverage. Plus 10% goes to the devs of the apps I do guides for every year.

Published inPlex 7.2

70 Comments

  1. Ron Ron

    So everything apeared tp be working. But I am pretty sure hardware encoding is not working.
    It worked when I had it installed outside the pod.
    Now when you are off the local network, the CPU hits 99% and the stream doesn’t start.
    I read somewhere about giving the pod admin permissions.
    Thought?

    • Dr_Frankenstein Dr_Frankenstein

      Hey so you shouldn’t need to grant the container root permissions, when playing something off the network take a look at the Dashboard in Plex and see what status you get for the transcode. Does it have a little ‘hw’ next to the video?

      • Ron Ron

        Wow, never knew you could see that there. THANKS.
        So after some more digging, I ended up trying someone elses advice suggesting to change max_user_instances and max_user_watches. That SEEMS to have helped. Not sure if it will reset in reboot yet. The transcoading is happening now. I do feel like this is a little janky.
        The error I was getting when it tried to transcode was “”error reading output: -5 (I/O error)”. I tried deleting the Cache and Codecs folders and restarting. This all seems like a hack instead of a solution.
        I appreciate any ideas.
        BTW, this is probably the best tutorial I have ever seen in my years.

        • Dr_Frankenstein Dr_Frankenstein

          Hey not come across this before – however a bit of searching seems to turn up all sorts of fixes which line up with what you have tried.

          It may be worth checking permissions a nice way to clean up anything is to run the following which will ensure the dockerlimited user has appropriate permissions on all folders and files. (this assumes you are running Plex as per the guide and is on volume1.)

          sudo chown -R dockerlimited:users /volume1/docker/plex /volume1/data
          sudo chmod -R a=,a+rX,u+w,g+w /volume1/docker/plex /volume1/data

  2. Moe Moe

    I attempted to follow this tutorial; however, upon trying to build it, I encountered the error message: “Top-level object must be a mapping.”

  3. Stuart Stuart

    Should this be running on the host network or configured to use the synobridge network?

  4. Christopher Schwartz Christopher Schwartz

    Is there a benefit installing Plex as a docker container versus the DSM package that Plex provides?

    • Dr_Frankenstein Dr_Frankenstein

      Two main benefits

      1) No issues on a DSM upgrade, if the underlying system changes that breaks the Plex package you will not be down, this has happened a lot over the years.
      2) Portability – When your NAS is old, and you want to migrate Plex to something more powerful such as a NUC its lift and drop – copy the files – fire up the container with the same settings. I have done this multiple times as I have Plex on a NUC and moved it through 4 generations NUC6/NUC7/NUC8 and currently a NUC11

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

drfrankenstein.co.uk – writing Synology Docker Guides since 2016 – Join My Discord!