Last updated on 30 November 2023
Important or Recent Updates
Historic Updates | Date |
---|---|
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 variable | 25/10/2023 |
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.
/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:
Section | Setting |
---|---|
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.
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.
Variable | Value |
---|---|
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_CLAIM | 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 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.
Firstly, thank you for all your guides. They’ve helped so much.
I am not getting any media icons when I connect to Plex outside the local network. Everything works and streams fine. Just the movie/tv show images in the library viewer do not show.
Any ideas? Firewall on synology is off.
Well that’s certainly a new one! I have done a bit of a search and the odd post I found about this has no replies. Do you get the same results via app.plex.tv outside the network, just to see if it’s the app misbehaving.
First off, thank you for writing these guides!
My Plex Synology package (running on a 918+) has randomly started, well, stopping, with no errors in the logs. I figured it was as good a time as any to move it to a container, so I followed this and your Plex package-to-container guide.
For some reason though, when I’m running Plex from a container, I can’t see or claim the server.
Here’s what I’d done: I unclaimed the server via the web ui, shut down the package, followed the guide to build the container, grabbed the claim code, started the container, loaded http://[mysynologyip]:32400/web and logged in.
Looking at the container logs, I’m wondering about the “restart the container” and “server already claimed” messages … is that normal? The restart message persists when restarting the container as well.
2024/04/19 12:14:39 stdout Critical: libusb_init failed
2024/04/19 12:14:27 stdout [ls.io-init] done.
2024/04/19 12:14:26 stdout Starting Plex Media Server. . . (you can ignore the libusb_init error)
2024/04/19 12:14:26 stdout “[custom-init] No custom files found, skipping…
2024/04/19 12:14:25 stdout
2024/04/19 12:14:25 stdout
2024/04/19 12:14:25 stdout #####################################################
2024/04/19 12:14:25 stdout # plex token found in the preference file #
2024/04/19 12:14:25 stdout “# and restart the container, because there was no #
”
2024/04/19 12:14:25 stdout # Login via the webui at http://:32400/web #
2024/04/19 12:14:25 stdout #####################################################
2024/04/19 12:14:25 stdout
2024/04/19 12:14:25 stdout
2024/04/19 12:14:25 stdout
2024/04/19 12:14:25 stdout **** The device /dev/dri/card0 does not have group read/write permissions, attempting to fix inside the container. ****
2024/04/19 12:14:24 stdout **** adding /dev/dri/card0 to video group root with id 0 ****
2024/04/19 12:14:24 stdout **** adding /dev/dri/renderD128 to video group videorsxt with id 937 ****
2024/04/19 12:14:24 stdout **** creating video group videorsxt with id 937 ****
2024/04/19 12:14:22 stdout **** Server already claimed ****
Did you completely remove the existing Plex Package just to make sure you are not seeing the log / error due to that being present still
I didn’t — I just stopped the package. Should I remove the package, and if so, should I choose the Uninstall Only, the Uninstall and Unclaim, or the Erase option?
(Sorry about the n00b questions)
I uninstalled and unclaimed the PMS Synology package, then I recreated the Docker container and viola!
Thanks for the help! Now on to rescanning all those library media files …
Nice one 🙂