Installing Plex on Ubuntu 22.04 with an Intel Gen 11 CPU using Docker

This guide is designed for installing Plex on a vanilla Ubuntu 22.04 LTS system running on an Intel Gen 11 (Tiger Lake) cpu via Docker.
I choose Docker over bare metal / native due to the ease of long term maintenance when using Docker compared to being installed directly on the host. I have run Plex both ways and I prefer Docker, even on a dedicated Plex server.
Prerequisites
- Ubuntu 22.04 installed
- Root access
- Internet access
If you run into any problems with the steps, try the reference links. They will often have more detailed information for a specific task, my instructions follow the happy path, ie: everything went fine the first time and with problems.
These optional steps are not required and you can skip them if you want.
Optional Steps
Install nano. Nano is a text editor that I prefer over vi or others.
sudo apt install nano
Install package updates. I suggest having all your packages current before beginning, but it isn't necessary. Any packages that need to be updated by the required components will be during the process.
sudo apt update && sudo apt upgrade
Install the Intel Compute Runtime Components
The Intel Compute Runtime components are used by Plex for hardware encoding/decoding on Linux systems. If you don't have these components installed any transcoding done with be in software only.
For this install I am using the current version of the runtime, 22.37.24175. You can substitute a different or newer version by downloading the components for that release from https://github.com/intel/compute-runtime. Other then the version you download and use (the wget commands) the instructions below are the same across releases.
Create a temporary directory to download the components.
mkdir ~/neo
Download the runtime components to the temporary directory
cd ~/neo
wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.12037.1/intel-igc-core_1.0.12037.1_amd64.deb
wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.12037.1/intel-igc-opencl_1.0.12037.1_amd64.deb
wget https://github.com/intel/compute-runtime/releases/download/22.37.24175/intel-level-zero-gpu-dbgsym_1.3.24175_amd64.ddeb
wget https://github.com/intel/compute-runtime/releases/download/22.37.24175/intel-level-zero-gpu_1.3.24175_amd64.deb
wget https://github.com/intel/compute-runtime/releases/download/22.37.24175/intel-opencl-icd-dbgsym_22.37.24175_amd64.ddeb
wget https://github.com/intel/compute-runtime/releases/download/22.37.24175/intel-opencl-icd_22.37.24175_amd64.deb
wget https://github.com/intel/compute-runtime/releases/download/22.37.24175/libigdgmm12_22.1.8_amd64.deb
Install the package as root
sudo dpkg -i *.deb
Cleanup the downloads after installing the runtime.
rm -Rf ~/neo
Note on HDR to SDR Hardware Tone Mapping
The Plex instructions say you need to install ocl-icd-libopencl1 and beignet-opencl-icd to enable HDR to SDR tone mapping in hardware.
In Ubuntu 22.04, beignet-opencl-icd, isn't a supported package. What I read seems to say later CPU's don't require this, so I am skipping those particular instructions for the time being. For reference they are:
sudo apt install ocl-icd-libopencl1 beignet-opencl-icd
Note on Intel CPU/GPU Drivers
The Intel drivers are in the package intel-media-va-driver. There is a non-free version of this called, intel-media-va-driver-non-free. The difference between the two is that the non-free version includes some proprietary components and is also needed for hardware encoding.
The naming convention leaves something to be desired as it is free to the user. The non-free version is not installed by default, so install that to have full hardware decode/encode capabilities.
It is also worth noting that I am haven't verified that the non-free version is required. I didn't see Plex mention it, but other guides have mentioned using it, and I don't see any reason not to at this point.
sudo apt install intel-media-va-driver-non-free libmfx1
Install Docker
First start by removing any old versions of Docker that might be installed by default. If you are already using Docker, you can skip this entire section.
sudo apt-get remove docker docker.io containerd runc
Cleanup any unused packages.
sudo apt autoremove
Install components used for setting up the Docker repository.
sudo apt install ca-certificates curl gnupg lsb-release
Add Dockers official GPG key.
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Update the Apt repository to include the Docker repository when using apt commands.
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install Docker.
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Optional - Connecting Your NAS to the Host System
If you keep your media on the same server as where you are hosting Plex, this section isn't necessary. If you keep your media on a NAS or other server, you will need to setup file sharing so that Plex can access the media.
All my media is hosted on a separate network attached storage system, using NFS to connect to the shared folders. I have my files split into three NFS shares, one for music, one for photos, and one for video.
This part is mostly for my own reference, but if you want to use NFS these are the instructions to get the client portion of NFS setup. You will still need to setup the NFS server that hosts the NFS shares. This assumes that is already done.
Install the NFS client packages.
sudo apt install nfs-common
Create a directory for the NFS mounts to live.
sudo mkdir /media/video
sudo mkdir /media/photo
sudo mkdir /media/music
Setup the shares to mount at boot up.
sudo nano /etc/fstab
Add to the fstab file the following entries, adjusting the IP address and the NFS share name.
<NAS_SERVER_IP>:/volume1/video /media/video nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0
<NAS_SERVER_IP>:/volume1/photo /media/photo nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0
<NAS_SERVER_IP>:/volume1/music /media/music nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0
Mount the new shares.
sudo mount -a
Optional - Script to Monitor NAS Connections
Sometimes during a power failure or other similar issue, the NAS may not boot up as fast as the Plex server. This can result in the media drives not being mapped and Plex showing content as unavailable.
You can create a simple script that checks for a folder in the media folder locations, and if it doesn't exist it will try to remount the remote drives. Then you use cron to schedule this to run every 10 minutes.
First create the script.
sudo nano /opt/plex/drive_check.sh
Add the following lines, substituting /media/video with one of the mounts points you are using. Right now I have it attempting to remount everything, but you could replace it with the specific mounts points if you wanted. This checks to see if the mount point exists and if it doesn't attempts to remount everything in /etc/fstab.
#!/bin/bash
if ! grep -qs '/media/video' /proc/mounts; then
mount -a
fi
Give the script execute permissions.
sudo chmod 555 /opt/plex/drive_check.sh
Then put the script in crontab running as root to check every 10 minutes.
sudo crontab -e
Add the following line at the end.
*/10 * * * * /opt/plex/drive_check.sh
Install the Plex Docker Image
Create the directories used by the Plex Docker container on the host server
sudo mkdir /opt/plex
sudo mkdir /opt/plex/{config,transcode}
Obtain a Plex claim token, which is necessary for your Plex server to tie to your Plex account. If server is already logged in, this parameter is ignored. You can obtain a claim token to login your server to your plex account by visiting https://www.plex.tv/claim
The claim token may expire, so you may need to go back and get a new one and reenter the new claim token into the docker-compose.yml file, depending on how long the remaining steps take you.
Create a docker-compose.yml for configuring the container. I use Nano for my text editor, but you can use whatever you like.
sudo nano /opt/plex/docker-compose.yml
Enter in the configuration for your Plex server. I am using the official Plex docker image, but if you are using LinuxServer.io or other image, the values may vary. The site that hosts each image almost always has documentation on the various options. The following is what mine configuration looks like.
version: "3.9"
services:
# Name of the service we are starting
plex:
# User friendly name for the container
container_name: plex
# Which image to use for the container, public, beta, or latest
# public and beta will self update with a restart of the container
image: plexinc/pms-docker:public
# Automatically restart the container unless it was manually stopped
restart: unless-stopped
# Configure the network, host or bridge, host uses the host network
# Host networking is the easiest, if using bridge, a number of other
# options need to be included that are not in this config
network_mode: host
environment:
# Set the timezone for the container, eg: America/Chicago
- TZ=America/Chicago
# Token from https://www.plex.tv/claim needed to automatically login
# and register this container with your Plex account
- PLEX_CLAIM=<insert_your_claim_token>
# Internal Networks
- ALLOWED_NETWORKS=192.168.0.0/24,192.168.10.0/24,192.168.20.0/24,192.168.30.0/24
volumes:
# The format is <host_path>:<container_path>
# path to where the plex database/configuration files will be stored
- /plex/config:/config
# path to where the temporary transcode files will be stored
- /plex/transcode:/transcode
# path(s) to where your personal media is
- /media/video:/media/video
- /media/photo:/media/photo
- /media/music:/media/music
devices:
# enable hardware assist when using Intel Quick Sync supported CPUs
- "/dev/dri:/dev/dri"
Test the container to make sure it is formatted correctly, and fix any errors you find.
sudo docker-compose -f /opt/plex/docker-compose.yml config
Start the container. Reminder to get a new claim token if this took you more then four minutes, which it most likely did.
cd /opt/plex
sudo docker-compose up -d
Optional - Setup Plex to Auto Update Weekly
If you are using the Public or Beta tags, you can setup Plex to auto update the Plex version by simply restarting the container. The easiest way to do this is to set a cron job to restart the container weekly.
I restart mine every Monday at 3:30am. You can use https://crontab.guru/ if you aren't familiar with cron and want to set a different schedule.
My cron command line looks like this:
30 3 * * 1 docker restart plex
Replace plex with the name of your container, which is defined in the docker-compose.yml file.
You edit the crontab as user root with the command:
sudo crontab -e
You can verify this was updated correctly by the command:
sudo crontab -l
The results should look similar to this.
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
30 3 * * 1 docker restart plex
References

