My old server had 12 CPU cores with hyper-threading giving 24 available threads. However, as a Plex server it wasn't ideal as the Xeon processors don't have the Intel quicksync capabilities. My mini-pc, however, does have Intel quicksync capabilities on it so I decided to move Plex (and Jellyfin) to the mini-pc in order to utilise this feature even though it is my main desktop. Plex is now on the HP NL54 microserver being used as a NAS with a GPU for the transocding
The mini-pc is a 4 core third generation i5 CPU and is far less powerful than my server but when transcoding a 4K movie down to 720p is only using 50% of the CPU (effectively 2 cores) whilst the same operation on the server was maxing out approximately 8 cores...
So that I could keep Plex away from the main OS install I decided to use a docker container. This also means that I can change the OS if I want and after installing the docker runtime on the new OS, Plex is available straight away as long as I don't wipe the docker partition during the install (yes, I did do that once and had to rebuild the Plex library and lost all the tracking of what had been watched etc.)
In order to use quicksync the device has to be exposed to the container. This is achieved by the following line in the docker compose script.
devices:
- /dev/dri/:/dev/dri/
This is for the integrated Intel GPU on my hardware. Other hardware may require different devices but the principle is the same.
Media Storage
Now that Plex is running on the mini-pc rather than the main server I have to provide access to the media for Plex to use as the 480GB SSD in the mini-pc is not going to hold much in the way of media. Initially I just added a line to /etc/fstab
mounting the nfs share containing all the media but I discovered that this had a potential issue too.
If the nfs share was not available when the mini-pc booted up and tried to mount the nfs share then plex would start but not connect to the nfs share (expected as it's not available) but even when the main server was available again I discovered that Plex was still reporting that the media was not available. Not a major issue if I was home, as logging on and restarting stuff at home takes a few seconds; but if I'm away from the house and trying to watch something then it's far from ideal. To combat this I decided to automatically mount the nfs share when it's required.
Example docker compose file using an nfs share as the storage. Ensure that the location specified for the docker /config
directory has plenty of space if your media library is quite large. Currently I'm using about 13GB for the Plex catalog. The /transcode
directory is a dedicated file system on the host used for storing the temporary files when transcoding. If not specified as a separate location then the Plex container will default to using a location under the /config
directory.
version: "3.1"
services:
plex:
image: ghcr.io/linuxserver/plex
container_name: plex
ports:
- 32400:32400
- 8324:8324 #optional
- 32410:32410/udp #optional
- 32412:32412/udp #optional
- 32413:32413/udp #optional
- 32414:32414/udp #optional
environment:
- PUID=1000
- PGID=1000
- VERSION=docker
- PLEX_CLAIM=<plex claim token> # only required on first start
volumes:
- /var/lib/docker/volumes/config/plex:/config
- /nfs/multimedia:/multimedia
- /transcode:/transcode
devices:
- /dev/dri/:/dev/dri/
Plex Claim Token
If the claim token is not added during initial configuration you will need to use ssh tunneling to gain access and setup the server for first run. During first run you setup the server to make it available and configurable.
However, this setup option will only be triggered if you access it over http://localhost:32400/web
, it will not be triggered if you access it over http://ip_of_server:32400/web
. If you are setting up Plex on a headless server, you can use a SSH tunnel to link http://localhost:32400/web
(on your local computer) to http://localhost:32400/web
(on the headless server running Plex):
ssh username@ip_of_server -L 32400:ip_of_server:32400 -N
To get your claim token go to https://plex.tv/claim
, log into your plex account and copy the token. Add it into the config and start the container. The token is only valid for about 5 minutes after you create it so make sure to start the container as soon as possible after claiming the token.
Limiting resources used by Plex
If you wish to limit the resources used by Plex then something along the lines of the below can be added to the docker compose file.
deploy:
resources:
limits:
cpus: 2.0
memory: 2048M
This section limits Plex to using 2 CPU cores and a maximum of 2GB RAM ensuring that it doesn't take all available resources. This means that even when Plex is transcoding a movie I can still use the PC without being affected too much.