How To Run Plex Media Server in Docker Containers

Posted on 233 views

A media server is a computer system for storing digital media such as videos, images, and audio files. These files can be accessed and shared via the internet. There are several media servers such as; Subsonic, Emby, Madsonic, Gerbera, Universal Media Server, LibreELEC, Red5 OSMC, Kodi, Tvmobili, OpenFlixr, Jellyfin e.t.c.

Plex media server is a powerful full-featured server that allows one to stream media over the internet via compatible devices. Plex can be installed on Linux, macOS, Windows e.t.c. Plex has a simple interface and it organizes the data in beautiful libraries that make it easy for one to access them.

The features and benefits associated with Plex are:

  • Allows you to easily pick and choose what to share.
  • Supports cloud sync.
  • Offers the parental control functionality.
  • Supports encrypted connections with multiple user accounts.
  • Supports flinging of video from one device to another.
  • Has a media optimizer for Plex Media Player.
  • Supports audio fingerprinting and automatic photo-tagging.
  • Supports mobile sync which offers offline access to your media files.

This guide describes how to run Plex Media Server in Docker Containers.

Setup Pre-requisites

Update your system and install the required packages using the commands:

## On RHEL/CentOS/RockyLinux 8
sudo yum update
sudo yum install curl vim

## On Debian/Ubuntu
sudo apt update && sudo apt upgrade
sudo apt install curl vim

## On Fedora
sudo dnf update
sudo dnf -y install curl vim

Step 1 – Install Docker and Docker Compose

Before you proceed with this guide, you need Docker installed on your system. It can be installed using the dedicated guide below:

Once installed, ensure that the Docker Engine is started.

sudo systemctl start docker && sudo systemctl enable docker

Also, add your user account to the Docker group.

sudo usermod -aG docker $USER
newgrp docker

You can also install Docker Compose if you wish to run Plex from the Docker-Compose YAML file. Installing Docker Compose can be accomplished with the aid of the guide below:

Step 2 – Create a Persistent Volume for Plex

For the Plex data to persist, you need to create/mount the volumes on your system. There are several volumes required. Create the volumes as below.

sudo mkdir /plex
sudo mkdir /plex/database,transcode,media

On Rhel-based systems, you need to set SELinux in permissive mode for these paths to be accessible.

sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config

Step 3 – Run Plex Media Server in Docker Containers

This guide provides two ways how to run the Plex Media Server in Docker Containers i.e directly with docker and using Docker-compose. With these methods, you can use 3 networking types:

  • Bridge – This is the default networking, it creates an entirely new network within the host and runs containers within it.
  • Host – This networking uses the IP address of the host running docker such that a container’s networking appears to be the host rather than separate.
  • macvlan – networking creates a new virtual computer on the network which is the container.

Setting up Plex using host and macvlan networking is easier and requires fewer workarounds. The docker files will be as below.

  • For Macvlan Networking

If using Macvlan Networking run the commands below:

docker run \
  -d \
  --name plex \
  --network=physical \
  --ip= \
  -e TZ="" \
  -e PLEX_CLAIM="" \
  -h  \
  -v /plex/database:/config \
  -v /plex/transcode:/transcode \
  -v /plex/media:/data \
  • For Host Networking
docker run \
  -d \
  --name plex \
  --network=host \
  -e TZ="" \
  -e PLEX_CLAIM="" \
  -v /plex/database:/config \
  -v /plex/transcode:/transcode \
  -v /plex/media:/data \

For this guide, I will demonstrate how to run Plex using the bridge(default) networking. Here several ports are exposed.

docker run \
  -d \
  --name plex \
  -p 32400:32400/tcp \
  -p 3005:3005/tcp \
  -p 8324:8324/tcp \
  -p 32469:32469/tcp \
  -p 1900:1900/udp \
  -p 32410:32410/udp \
  -p 32412:32412/udp \
  -p 32413:32413/udp \
  -p 32414:32414/udp \
  -e TZ="Africa/Nairobi" \
  -e PLEX_CLAIM="claim-ey6ekAqeQjosd1P" \
  -e ADVERTISE_IP="" \
  -h \
  -v /plex/database:/config \
  -v /plex/transcode:/transcode \
  -v /plex/media:/data \

In the above command, obtain the PLEX_CLAIM using the URL If this token is not provided, you cannot automatically log in to Plex.

Alternatively, you can use Docker Compose to run the Plex container with bridged networking as below.

Create a docker-compose.yml file

vim docker-compose.yml

In the file, add the below lines, replacing appropriately

version: '2'
    container_name: plex
    image: plexinc/pms-docker
    restart: unless-stopped
      - 32400:32400/tcp
      - 3005:3005/tcp
      - 8324:8324/tcp
      - 32469:32469/tcp
      - 1900:1900/udp
      - 32410:32410/udp
      - 32412:32412/udp
      - 32413:32413/udp
      - 32414:32414/udp
      - TZ=Africa/Nairobi
      - PLEX_CLAIM=claim-ey6ekAqeQjosd1P
      - /plex/database:/config
      - /plex/transcode:/transcode
      - /plex/media:/data

You can run the container with docker-compose using the command:

docker-compose up -d

Once the container has started, view the status as below.

$ docker ps
CONTAINER ID   IMAGE                COMMAND   CREATED         STATUS                            PORTS                                                                                                                                                                                                                                                                                                                                                 NAMES
baf1e1a3b806   plexinc/pms-docker   "/init"   5 seconds ago   Up 2 seconds (health: starting)>3005/tcp, :::3005->3005/tcp,>8324/tcp, :::8324->8324/tcp,>1900/udp, :::1900->1900/udp,>32410/udp, :::32410->32410/udp,>32400/tcp, :::32400->32400/tcp,>32412-32414/udp, :::32412-32414->32412-32414/udp,>32469/tcp, :::32469->32469/tcp   plex

Step 4 – Access the Plex Web UI

AT this point, Plex is running with the Web accessible via the set URL http://IP_address:32400


The Plex UI will load with the Plex Claim automatically loaded for the account set, proceed, and sign in to the dashboard.


On this dashboard, you can watch live TV, movies, shows, podcasts, listen to music, and add your media. Live Tv can be watched y selecting the desired channel.


Watch online movies and shows:


You can as well add media to Plex


Media can be added to the server as below.


To make settings to Plex, navigate to the settings tab and make the desired settings.


Step 5 – Manage the Plex container.

The Plex container can be managed as below.

##To stop
docker stop plex

##To start
docker start plex

The container can also be managed as a system service by creating a service file for it as below:

sudo vim /etc/systemd/system/plex-container.service

In the created file, add the lines below.

Description=Plex container

ExecStart=/usr/bin/docker start -a plex
ExecStop=/usr/bin/docker stop -t 2 plex


Save the file and reload the system daemon.

sudo systemctl daemon-reload

Now start and enable Plex to run automatically on boot.

sudo systemctl start plex-container.service
sudo systemctl enable plex-container.service

Check the status of the service.

$ systemctl status plex-container.service
 plex-container.service - Plex container
   Loaded: loaded (/etc/systemd/system/plex-container.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2022-03-09 10:42:24 EST; 10s ago
 Main PID: 59416 (docker)
    Tasks: 8 (limit: 36438)
   Memory: 17.3M
   CGroup: /system.slice/plex-container.service
           └─59416 /usr/bin/docker start -a plex

Mar 09 10:42:24 localhost.localdomain systemd[1]: Started Plex container.

That is it!

This is the end of this guide on how to run Plex Media Server in Docker Containers. I hope this was significant to you.

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.