Plex on Docker, for those with Plex Pass, can take advantage of hardware transcoding if your CPU offers it. Plex docker container from LinuxServer has the extra packages necessary for hardware-accelerated HDR to SDR tone mapping.
I hesitated migrating Plex to Docker because I assumed that getting hardware transcoding to work would be a pain, or impossible. Turns out it’s one line in docker compose.
I have lots of 4K movies with HDR that were choking when being transcoded. It turns out that while my 1019+’s CPU has hardware for HDR tone mapping, Plex requires a few extra packages to be installed for it to work: ocl-icd-libopencl1 and beignet-opencl-icd (See https://support.plex.tv/articles/hdr-to-sdr-tone-mapping/)
I figured that a properly maintained Docker image would have these dependencies installed and I was correct. I could probably install these myself on my Synology directly but then it’s more stuff to fuss with and I know the “right” solution is Docker, so why not try?
How I migrated Plex from DSM to Docker:
I used this article as a baseline: https://support.plex.tv/articles/201370363-move-an-install-to-another-system
I’m also using information from Linuxserver’s Plex image readme: https://hub.docker.com/r/linuxserver/plex
Part 1: Preparing Data
- Disable Emptying of trash in Settings->Library
- (Skip Install Plex on the destination)
- Sign out of the Plex server in Settings->General
- Stop DSM Plex using Package Center
- Get ready to copy your Plex data. I have my Docker configuration directories in their own share at /volume1/docker/[appname]. I’ll use /volume1/ as my root but adjust for the paths that make sense on your system.
- Create a few containing folders for Plex’s data. In my case it was /volume1/docker/plex/Library/Application Support
- Copy the Plex Media Server directory from /volume1/PlexMediaServer/AppData/ to /volume1/docker/plex/Library/Application Support/
- In the end you should have a folder that contains Library/Application Support/Plex Media Server. I know this pathing seems odd but it’s what the docker image will expect. This containing folder will be mapped to /config in the Docker container.
- If you’re migrating from Windows or macOS there are additional files to copy over mentioned in the guide but if you’re coming from DSM Plex you’re done with file prep. Now is time to set up Docker.
Part 2: Setting up the Docker Container
When I first got my Synology I used the GUI Docker tools to set up my containers. I was new to Docker and appreciated the visual interface. Now that I’m more familiar with Docker I’ve moved all of my containers over to Docker Compose and prefer it. What I didn’t realize is the that Synology GUI is still just as useful as it was without docker compose. Even if a container is managed via compose, it still shows up in the list, I can still open up the details on a container, view its logs, etc. Edits to the container’s settings still need to be made in the compose file however.
I’m using the LinuxServer.io plex docker image: https://hub.docker.com/r/linuxserver/plex#application-setup. Take some time and read through their documentation. For reference here’s my docker compose entry for plex. If you don’t want to use docker compose, you’ll still have to launch the container via the command line as there’s no way (that I know of) to map devices in the GUI.
plex: image: lscr.io/linuxserver/plex:latest container_name: plex network_mode: host environment: - PUID=1234 - PGID=5678 - VERSION=latest devices: - /dev/dri:/dev/dri volumes: - /volume1/docker/plex:/config - /volume1/TV:/volume1/TV - /volume1/Movies:/volume1/Movies - /volume1/Music:/volume1/Music restart: unless-stopped
A couple of notes here:
- PUID and PGID are specific to Linuxserver images and are the Linux UserID and Group ID you would like the image’s commands to run as. In my case I have them set to a user I made for Plex that only has access to the folders it needs to. To get the user ID and group ID of your users SSH into the Synology and run cat /etc/passwd. User ID is the first number, Group ID is the second.
- The VERSION environment variable is related to how Plex gets updated. This is different than the docker image tag of “latest”. The 4 options here are “docker”, “latest”, “public” “specific version number”. Whenever you restart the container it will grab and install the latest version of Plex matching your setting here and then continue the boot process. You can read about each option in the Linuxserver image’s readme.
- The devices entry is the critical component of getting hardware transcoding to work.
- My volume mapping looks a little odd, why am I mapping to /volume1/ on the docker side? Because this way all my library paths are identical from the DSM Plex installation. Maybe I didn’t have to do this but it made the transition seamless.
Part 3: Launching the Plex Docker Container and completing the transition
- Launch the docker container by using sudo docker-compose up -d in the same folder as your docker-compose.yml file via SSH or using the docker create command via SSH if you don’t want to use compose.
- Once the server is up and running visit it at your-nas-address:32400
- Go to Settings->General and claim the server with your Plex account.
Part 4: Cleanup
Follow the rest of the steps as indicated in Plex’s migration guide:
- Edit any library differences now that the media folder locations may have changed.
- Scan your library
- Turn “Empty Trash automatically…” back on in Settings->Library
- Empty Trash for the server
- Clean Bundles
- Optimize Database
Part 5: Updates
As stated in the notes section under the docker compose file, all you have to do is be logged in with your Plex account in Plex’s general settings and restart the container. The Linuxserver image’s scripts will take care of the rest.
Why move it to Docker?
Because I discovered that while the DSM version can take advantage of my Intel CPU’s hardware transcoding, it wasn’t taking advantage of its ability to do hardware HDR tone mapping, which meant transcoding 4K HDR movies would “work” but only play back for a few seconds before buffering would kick in.
Can my CPU do hardware transcoding and hardware HDR tone mapping?
- Check this Wikipedia table for broad compatibility: https://en.wikipedia.org/wiki/Intel_Quick_Sync_Video#Hardware_decoding_and_encoding
- Here’s Plex’s notes on transcoding: https://support.plex.tv/articles/115002178853-using-hardware-accelerated-streaming/
- And here’s a spreadsheet of NAS devices and what transcoding they support: https://docs.google.com/spreadsheets/d/e/2PACX-1vTvlMTD0d7yzOwEk5Cdqhq1_g55dZgXRoGy_wdZ-wT_bpYFhMVRsLSTrLNuFc1Rq0BKeyimWit25HD8/pubhtml
Why do you need HDR tone mapping?
Technically you don’t, you can leave this option off. However the video quality might look weird, dim, or generally off unless the high dynamic range information is mapped to standard dynamic range.
Why do you need Transcoding at all? Just use direct play.
I use direct play while at home, but when I’m out of the house or have friends accessing my Plex box I can’t directly serve an HDR 4k file.
Why not host two libraries with 4k content for home and 1080p content for everywhere else?
If you want to manage that more power to you, but I didn’t.
How do you keep Plex up to date?
LinuxServer’s docker image has a property called VERSION that it checks when the container boots up. Depending on what you select, and if you have a valid Plex pass token in the container, it will download and install the latest version of Plex then continue the boot process. There are tools they list on their docker page to notify you of when a new version is available and when it’s time to restart your container. TL;DR, just reboot the container.
Why not use Plex’s own Docker image instead of LinuxServer’s?
I use LinuxServer’s images for lots of other services and have had good luck with them. They also update them to keep pace with the core software’s new versions. If anyone wants to chime in with experiences using Plex’s official Docker image I’m all ears.
You did X wrong!
Not a question but tell me about it and I’ll fix it! I’m still fumbling through this stuff the best I can.