How to Install Plex on a Synology Using Docker

In this post I’m going to show you how you can run the media server Plex in a Docker container on your Synology NAS.

First, be sure that your Synology supports Docker. You need a Synology that has a CPU with the x86 architecture. Most cheaper models have a CPU with the ARM architecture which will not work. You can check out here which CPU architecture your Synology has.

There are a few guides out there how to get Docker running on unsupported models but make no mistake—even if you could somehow get Docker running on an unsupported platform, those cheaper models with ARM CPUs are simply too weak to run Docker containers. The cheapest model with Docker support currently is the DS218+, but it has only 2 GB of RAM. 2 GB of RAM will allow the Synology to run a few—maybe five—containers at the same time but not more. You’ll want to use a more potent Synology with enough RAM if you want to run more Docker containers at the same time. I use a DS918+ which has 4 GB of RAM by default and a free slot for additional RAM. It runs Docker containers very well.

Why Use Docker Containers Anyway?

Some DSM updates (e.g. the DSM 6 betas) have broken the Plex installation in the past. This could happen again with any DSM update in the future, since there’s always the risk that a DSM update removes or alters a package’s dependencies. Not so with Docker containers. With Docker, you bundle an application together with its dependencies into isolated containers and thus separate application dependencies from infrastructure. Docker basically adds a layer of abstraction that prevents things from going wrong.

Furthermore, the Plex package is cumbersome to upgrade. Docker makes it easier to always have the latest version of Plex.

Docker and Hardware Transcoding

There’s one (potential) downside of running Plex in a Docker container. If you run Plex in a Docker container, you won’t be able to make use of the efficient hardware transcoding chip inside your Synology. This chip was specifically built and optimized solely for the purpose of transcoding. Instead, your CPU—which was not specifically built for transcoding—will do all the transcoding work via software. This imposes quite a burden on the system. To enable hardware transcoding, you need to run Plex as a package and also pay for the Plex Pass.1

If you’re not paying for the Plex Pass, it doesn’t matter whether you’re running Plex in a Docker container or as a package—you won’t be able to make use of hardware transcoding in either case. But if you’ve purchased a Plex Pass subscription, you might want to consider to stop here and run Plex as a package instead.

For all non-subscribers: As long as your movies are all encoded with x264, you shouldn’t need hardware encoding anyway so long as you don’t plan to stream your movies over the internet from a hotel room. Still, if you’re watching your videos in the web app or on an iPhone/iPad, the audio track will have to be transcoded if it’s a DTS or AC3 track, since a web browser or iPhone/iPad can’t handle either of those. But software transcoding usually is sufficient for that. Transcoding audio tracks is by far not as demanding as transcoding video tracks. But I’m getting ahead of myself. Let’s get Plex up and running in a Docker container!

Install the Docker Package

Go to Synology’s Package Manager, search for “Docker” and install it. It’s pretty straight-forward.

Additional Steps

Before we can start using Docker containers we have to make some preparations.

Connect to your Synology with SSH

We will use the command line interface, so make sure that SSH is enabled on your Synology. You can find that option under Control Panel > Terminal & SNMP > Terminal. You should also have assigned a static IP address to your DiskStation.

Now that SSH is enabled, you can log in to your DiskStation. If you’re on Windows, I guess you have to use PuTTY for that. I’m not a Windows guy though, so follow this tutorial to configure PuTTY. It’s easier if you’re using macOS or Linux. Simply open the terminal on your computer and issue the following command (use your own user name and replace the IP address with your Synology’s IP address beforehand):

ssh david@192.168.x.x

Now enter that account’s password or copy & paste it from your password manager. The account you use to authenticate yourself has to have administrator rights otherwise it won’t work.

Download the Plex Image

Executing docker commands requires root privileges, i.e. you have to type sudo in front of every command. You can verify that by trying to download the Plex image right away. It will not work.

docker pull linuxserver/plex

You probably received the error message docker: Got permission denied while trying to connect to the Docker daemon socket at …. Let’s fix that!

Since running docker commands in combination with sudo can be dangerous, we’d rather avoid it. Instead, we heed the advice of this site:

If you don’t want to use sudo when you use the docker command, create a Unix group called docker and add users to it.

Due to DSM not being a full Linux system and lacking the mentioned tools such as usermod, we can’t use the commands that site is proposing to create the docker group. Instead, we use the following Synology-specific command (replace david with your own username):

sudo synogroup --add docker david

This command created a user group called docker and added the user david to said group. That means that the stated user can now issue docker commands without having to put sudo in front of them, because:

When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.

Next, re-evaluate your group membership. To do that, first, log out by typing exit into the terminal and then log back in using the same command as above.

For the effects to take place, we need to restart the docker daemon:

sudo synoservice --restart pkgctl-Docker

Alternatively, you could also use the GUI or these commands:

sudo synoservicecfg --stop pkgctl-Docker
sudo synoservicecfg --start pkgctl-Docker

Now test whether you’re able to run docker commands without sudo:

docker pull linuxserver/plex

This time, it should have worked. That command has also downloaded the Docker image for Plex by Linuxserver is a great resource for Docker images. Their Plex image is better than the official image from Plex. Their images have good documentation, are very well maintained, and—most importantly—they can auto-update without you having to download the latest image manually.

Create the Mount Points

Next, we need to create the volumes we’re going to mount later on. Sounds complicated but is really simple. Go back to the terminal, log back in if necessary, and create two new folders:

mkdir -p "/volume1/docker/plex/config"
mkdir -p "/volume1/docker/plex/transcode"

You may have noticed that Docker created a new shared folder called docker when you installed the Docker package. Inside that shared folder, we just created a new subfolder called plex and two sub-subfolders inside that plex folder. You should do that for every application you want to run in a Docker container, not just for Plex. The reason is: we don’t want an application to store its configuration files inside its container but somewhere we can access them. The whole purpose of Docker, after all, is that containers are meant to be disposable. If something doesn’t work anymore, throw the container away and create a new one. If you store your configuration files inside the container, you’d throw them away together with the container and lose all your settings. We’d rather store the settings outside the Docker container so that we can delete and create containers at will without having to reconfigure Plex each and every time. Since Docker containers cannot see the file system of their host, we’ll have to define mount points that point to specific folders—and we just created these specific folders.

In case you already had the Plex package installed before you decided to run Plex in a container, you can migrate your existing Plex settings to Docker by following this article. Basically, you just move the Library folder out of the shared folder called Plex inside the newly created folder /volume1/docker/plex/config. It’s best to use the GUI in your web browser to move that folder. If you want to do it from the terminal, you’d have to log in as root user, since you cannot see shared folders when you’re logged in as admin account (admin accounts are just regular accounts in this scenario).

Create the Docker Container

Finally, we can create the Docker container. Depending on how you organize your media, you will have to adjust the following command to your own specific situation. I have a shared folder called Media in which I have different subfolders called TV Shows, Movies, and Music. If your folders are named differently, replace the path to the left of the colon accordingly but leave the right side as is. If you don’t want to add e.g. your music to Plex, omit the appropriate line. If you’d like to also add your photos folder, add an appropriate line.

Since I live in Germany, my time zone is Europe/Berlin. You have to replace that with your own time zone (which you can find here).

Leave everything else as is. Copy the entire code snippet and paste it into the terminal as one single big command (log back in via SSH if necessary).

docker run \
--name=plex \
--net=host \
--restart=always \
-e VERSION=latest \
-e PUID=$(id -u) -e PGID=$(id -g) \
-e TZ=Europe/Berlin \
-v "/volume1/docker/plex/config":/config \
-v "/volume1/Media/TV Shows":/data/tvshows \
-v "/volume1/Media/Movies":/data/movies \
-v "/volume1/Media/Music":/data/music \
-v "/volume1/docker/plex/transcode":/transcode \

This command creates an actual container out of the image. Since we’re using --net=host, we don’t need to take care of any sort of port forwarding. There are applications and advanced use cases where you want to use bridge instead, but for our purpose of creating a simple Plex container host is sufficient and the preferred option.

A Word on Environment Variables

This section is solely for your information. It does not contain any commands you need to execute. If you’re not interested in the details, you may skip this section. I just want to inform you about one of the many reasons why I wasn’t quite content with the existing guides and wanted to write my own, more coherent guide.

In order for the Docker container to access your media, we first need to give it permission. Most other guides would make you find out your user ID (UID) manually (it should be a four-digit number around 1026). Then, these guides would make you write that number down somewhere and save it for later. Next, they would make you find out your group ID (GID)—manually again. Both of which would be achieved using the command id. Then, these guides would have you set PUID equal UID and PGID equal GID. All of this would be done manually. This is not very efficient. I spared you that. If you take a closer look at the command from above, you will notice the line -e PUID=$(id -u) -e PGID=$(id -g). This line does everything mentioned automatically for you. It also obviates the risk of setting the wrong group ID. The group ID 100 stands for the user group, the group ID 101 for the administrator group. Since you’re logged in as administrator, the id command would show that your account belongs to both 100 and 101. Many guides would make you set 101 as PGID. I don’t recommend that. Unless you really want to grant Plex administrator rights—which you shouldn’t do and certainly do not need to do—you should set 100 as PGID (and thus give Plex the access permissions of a regular user). 100 is also what id -g returns. I hope this made the command from above a little bit clearer.

Open Plex

The container should have started by now. If not, give it a few more second. Now, you can finally start using Plex. Replace the IP address in http://192.168.x.x:32400/web with your own Synology’s address, open that URL in your web browser and save it as a bookmark.

In Plex, you’ll probably have to adjust some settings, e.g. add the tvshows, movies, and music folders to your media library. Apart from this, that’s it! I hope you now have a working Plex setup.

Fix Transcoding Issues

I used to have a lot of problems with transcoding. Despite all my media was encoded into the correct format, i.e. it should have qualified for Direct Play/Direct Stream, Plex was still transcoding it. This made Plex unusable for me. I watch a lot of Game of Thrones which makes heavy use of subtitles. With the wrong settings, Plex would “burn in” the subtitles, thus making it necessary to transcode the video stream. To fix this problem, first of all, be sure that all subtitles are external files and in the SRT format. Then, in the Plex settings, enable the advanced settings and go to Web > Player > Burn subtitles and change it from Automatic to Only image formats. This solved my transcoding problems.

Image of best subtitles setting

If you liked this article, please share it with your friends. Feel free to post it in some forums. As you can see by now, running Plex in a Docker container is not that hard once you’ve wrapped your head around it. I found the existing guides to be very confusing, however. It would be great if I could help some more struggling people out. Cheers!

  1. Be sure to download the Plex package directly from Plex rather than from the Synology Package Manager. The version found in the Synology Package Manager is abandoned and thus massively out of date. It’s still 32-bit software and doesn’t support hardware encoding either.