In our modern era of digital entertainment, a dependable and user-friendly media server has become essential for numerous homes.
A media server enables you to save, arrange, and stream your cherished movies, TV series, music, and images to a range of devices on your home network.
In this blog post, I’ll walk you through the steps to create a headless Linux media server utilizing Plex and Docker. These two robust and versatile tools can streamline the process and elevate your multimedia experience.
Plex: A Comprehensive Media Solution
Plex is a popular media server software that organizes your media library and makes it accessible across various devices, including smart TVs, streaming devices, smartphones, and web browsers.
It features an intuitive user interface, automatic metadata fetching, and on-the-fly transcoding, ensuring your media is always presented in the best possible quality regardless of the device.
Docker: Containerized Applications
Docker is a platform that allows you to run applications in isolated containers. Containers make it easier to deploy and manage applications by bundling the application code, dependencies, and configurations into a single, portable unit.
This approach simplifies the installation process and reduces the risk of conflicts with other software on your system.
Prerequisites
Before we dive into the setup process, ensure that you have the following:
- A Linux-based system (e.g., Ubuntu, Debian, or CentOS) with root access
- A decent amount of storage space to store your media files
- A basic understanding of Linux terminal commands and text editing
Step 1: Install Docker and Docker Compose
To set up our headless Linux media server, we first need to install Docker and Docker Compose on the system. Docker Compose is a tool for defining and running multi-container Docker applications.
For Debian/Ubuntu-based systems, run the following commands to install Docker:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
For CentOS-based systems, run the following commands to install Docker:
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io
After installing Docker, start and enable the Docker service:
sudo systemctl start docker
sudo systemctl enable docker
Next, install Docker Compose by running the following commands:
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Verify the installation by checking the Docker and Docker Compose versions:
docker --version
docker-compose --version
Step 2: Configure Plex Media Server with Docker
Now that we have Docker and Docker Compose installed, we can proceed with setting up Plex Media Server using a Docker container.
First, create a directory to store Plex configuration files and media:
mkdir -p ~/plex-media-server/config
mkdir -p ~/plex-media-server/movies
mkdir -p ~/plex-media-server/tvshows
mkdir -p ~/plex-media-server/music
Next, create a docker-compose.yml
file in the ~/plex-media-server
directory:
cd ~/plex-media-server
touch docker-compose.yml
Open the docker-compose.yml
file with your preferred text editor, and add the following content:
version: "3.3"
services:
plex:
image: plexinc/pms-docker:latest
container_name: plex
network_mode: host
environment:
- TZ=Your_Time_Zone
- PLEX_CLAIM=claim-Your_Plex_Claim_Token
- ADVERTISE_IP=http://Your_Server_IP:32400/
volumes:
- ./config:/config
- ./movies:/data/movies
- ./tvshows:/data/tvshows
- ./music:/data/music
- /dev/shm:/transcode
restart: unless-stopped
Replace Your_Time_Zone
with your system’s time zone (e.g., America/New_York
), Your_Plex_Claim_Token
with the Plex claim token obtained from https://www.plex.tv/claim, and Your_Server_IP
with the IP address of your Linux server.
Step 3: Deploy Plex Media Server with Docker Compose
With the docker-compose.yml
file in place, it’s time to deploy the Plex Media Server container. Run the following command in the ~/plex-media-server
directory:
docker-compose up -d
This command will pull the latest Plex Media Server image from Docker Hub, create the Plex container, and start it in detached mode. The setup may take a few minutes to complete.
Step 4: Access and Configure Plex Web Interface
Once the Plex Media Server container is up and running, you can access the Plex web interface by navigating to the following URL in a web browser:
http://Your_Server_IP:32400/web
Replace Your_Server_IP
with the IP address of your Linux server.
Upon first access, you will be prompted to sign in with your Plex account. After signing in, the Plex setup wizard will guide you through the initial configuration, including:
- Naming your Plex server
- Adding your media libraries (Movies, TV Shows, and Music) by pointing to the respective directories we created earlier (
./movies
,./tvshows
,./music
) - Customizing Plex settings, such as enabling remote access and configuring metadata agents
Step 5: Add Media to Your Plex Server
With Plex Media Server up and running, you can now add your media files to the corresponding directories (./movies
, ./tvshows
, ./music
). Plex will automatically index the files and fetch metadata, such as movie posters, episode summaries, and album covers.
When adding new media, ensure the files follow Plex’s naming conventions for optimal recognition and metadata retrieval. For example:
- Movies:
Movie_Name (Release_Year).ext
- TV Shows:
Show_Name/Season XX/Show_Name - SXXEXX - Episode_Name.ext
- Music:
Artist_Name/Album_Name/Track_Number - Track_Name.ext
Conclusion
By setting up a headless Linux media server with Plex and Docker, you can enjoy a robust, flexible, and user-friendly solution for managing and streaming your media files across your home network.
With Plex’s intuitive interface, automatic metadata fetching, and on-the-fly transcoding, you can effortlessly
Related Topics:
Supercharge Your Linux Terminal Workflow with Tmux and Vim
Version Control on Linux with Git and GitHub
Downloading YouTube Videos in Linux Command Line with youtube-dl
How to Solve “stdin: not in gzip format” Error in Linux
Building a Robust Linux-based Mail Server with Postfix and Dovecot
Android APK – App Not Installed as Package Conflicts with an Existing Package