Skip to content

Plex in Docker on a Synology NAS (Hardware Transcoding)

Last updated on 30 November 2023

Please note if you are using DSM7.2 or higher you should use the Container Manager version of this guide from the menu.
This guide has reached the end of its updates as most people are now on the latest DSM update - This guide is correct as of 08/12/2023 however no further updates will be added.
UpdateDate
Amended the path to save the compose file – this is for security, so the container has no access to the file contents.14/04/2023
Historic updates now at the end of the guide.

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

As of writing the Synology UI does not have the capability of passing through specific hardware to a container, this means we will need to set up Plex via SSH (terminal). However, don’t freak out as it’s not that difficult!

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 here

Let’s Begin

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

Docker Compose

We will be using Docker Compose to set up the Plex container. In a nutshell we will be creating a text file (YAML formatted) which tells Docker exactly how we want to set up a specific container.

The next steps can be done either using a code/text editor such as Notepad++ or to keep things simple for this guide we will be using the Synology Text Editor which can be installed from the Package Center.

Install Text Editor from the Package Center

Open up Text Editor and click on File then New to start a new file.

You can now copy and paste the details below into the new text file, it is important you don’t change the spacing as YAML has to be formatted correctly in order to be read by Docker Compose.

YAML
services:
  plex:
    image: linuxserver/plex
    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
      - VERSION=latest
      - PLEX_CLAIM=
    volumes:
      - /volume1/docker/plex:/config
      - /volume1/data/media:/data/media
    devices:
      - /dev/dri:/dev/dri
    restart: unless-stopped

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.

Please 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 compose file in a few steps time.

PUID and PGID

When you created your docker user you would have noted down these IDs add these to the compose file in the ‘environment:’ section

Volumes

We can now pass through our file paths into the container they are mounted using the volume’s section of the compose file.

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.

Timezone

The timezone variable will tell the container where you are in the world meaning your logs and scheduled tasks will run at the correct times. A list of timezones with the correct formatting can be found here wikipedia.org/wiki/List_of_tz_database_time_zones

Your final file should look similar to the one shown below.

Saving the Compose File

We now need to save this file into our docker share.

Click on File then Save As, navigate to the ‘Docker’ share and create a new folder called ‘plex’ (lower case)

You need to change the ‘File name’ to plex.yml and save it in the ‘docker‘ folder

SSH and Docker-Compose

It’s time to get logged into your Diskstation via SSH, you can do this in the same way as when you obtained your IDs in the ‘Setting up a restricted Docker user‘ guide.

Once you have logged in you will need to give 2 commands, you can copy and paste these one at a time — you will need to enter your password for the command starting with ‘sudo’

First we are going to change directory to where the plex.yml is located, type the below and then press enter.

Bash
cd /volume1/docker

Then we are going to instruct Docker Compose to read the file we created and complete the set-up of the container. Again type the below and press enter.

Bash
sudo docker-compose -f plex.yml up -d

When the command has completed you should be able to see Plex running in the list of containers in the Synology GUI.

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

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.

Historic UpdatesDate
New guide released06/12/2021
Added note around Ryzen based Synology models27/12/2021
Updated Environment Variables to ensure server is updating to the latest version02/02/2022
Added Timezone Variable to the compose file22/05/2022
Amended the mount path for media12/08/2022
Amended the Plex image to pull from dockerhub to make updates easier18/08/2022
Updated the Hardware Transcode section it’s now much easier02/09/2022
Added the Optional Plex Claim to the Environment Variables18/02/2023
Compose version number removed and small wording amendments09/04/2023
Historic Updates

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.1

147 Comments

    • Dr_Frankenstein Dr_Frankenstein

      Hey, I would try to grab the latest version and try it out, the great thing is you can always roll back again if not.

  1. facadecakeday facadecakeday

    Hello! I followed this guide but for some reason I still cannot get hardware transcoding to work:

    ───────────────────────────────────────
    To support LSIO projects visit:
    https://www.linuxserver.io/donate/
    ───────────────────────────────────────
    GID/UID
    ───────────────────────────────────────
    User UID: 1027
    User GID: 100
    ───────────────────────────────────────
    **** Server already claimed ****
    **** creating video group videovbny with id 937 ****
    **** adding /dev/dri/renderD128 to video group videovbny with id 937 ****
    **** permissions for /dev/dri/card0 are good ****

    I also posted on reddit for some help there as well if you have time to review that post.

    https://www.reddit.com/r/synology/comments/13sj8xu/hw_transcoding_trouble_on_ds920_and_plex_docker/?sort=new

    • Dr_Frankenstein Dr_Frankenstein

      Was just replying to Zuko and Crytos

      I heard that there may be an issue with the latest container try rolling back to an older one from a couple of weeks ago change the image line in to compose to

      image: linuxserver/plex:1.32.1

      • facadecakeday facadecakeday

        That was the issue, I reverted back to the 1.32.1 version and hw transcoding is working correctly again.

        • Dr_Frankenstein Dr_Frankenstein

          Yup getting the same reports from Reddit so might be worth hanging back a bit.

  2. Crytos Crytos

    I used to get hardware transcoding to work via this docker but i noticed lately that it’s no longer working. I’ve re-created the container thinking it was just that but no luck. It’s been working flawlessly ever since i first set this up about 10 months ago.

    i checked that
    devices:
    – /dev/dri:/dev/dri

    was included in the docker compose.

    In the logs of the container though i see it saying it doesn’t have read/write to that area though. i’ve never noticed this error before.

    **** adding /dev/dri/renderD128 to video group root with id 0 ****

    **** The device /dev/dri/renderD128 does not have group read/write permissions, attempting to fix inside the container. ****

    **** The device /dev/dri/card0 does not have group read/write permissions, attempting to fix inside the container. ****

    GUID and GPID have not been changed and is what i have used all along.

    Any guidance would be appreciated.

    • Dr_Frankenstein Dr_Frankenstein

      Hey it sounds like something has changed with the permissions of the two devices it has mentioned – I will ping you an email on how to fix it in the next hour or so.

      • Zukio Zukio

        Could you shoot me the solution too? I have the same issue.
        Happend out of nowhere on a DS920+

        • Dr_Frankenstein Dr_Frankenstein

          Was just replying to facadecakeday and Crytos

          I heard that there may be an issue with the latest container try rolling back to an older one from a couple of weeks ago change the image line in to compose to

          image: linuxserver/plex:1.32.1

  3. Cyprian Cyprian

    Hello,

    thaks for your tutorial. I managed to install PMS with transcoding working as a charm.
    Somehow I realised, that PMS updated on its own and I cannot transcode anymore.

    Any ideas? Dont want to reinstall server 🙁

    Regards,
    Cyprian

    • Dr_Frankenstein Dr_Frankenstein

      Hey, when you say it updated on its own did you restart the container to pull the update? An update should not break transcoding. You can just delete the Container from the Docker UI and re-run the docker compose up command to rebuild, you will not lose any data as its all stored in the /docker/plex share.

  4. May be a stupid question but curious as to why use plex through docker versus through synology package center.

    Follow-up questions. Assuming my plex is working nicely through synlogy package centre is worth moving to docker and if so, is there an easy to migrate and keep settings?

    Thank you so much for you guides.

    • Dr_Frankenstein Dr_Frankenstein

      No difference from a day to day running perspective other than potentially faster updates.

      Long term Docker would be the go to based on historic issues with 3rd Party Packages breaking on major system updates. Migration thankfully is not to complex nowadays. If you are happy and working stick with it. But long run you may want to move over.

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!