Docker

Setup a Plex Server Using Docker Compose

Plex is a versatile multimedia management and streaming platform. It offers features such as efficiently cataloging and distributing the video, music, and photo content defined libraries.

One of Plex’s core functionality revolves around the aggregation of diverse media types and the seamless transmission of these files.

To facilitate this, Plex is encapsulated within a self-contained entity which is known as the Plex Media Server which ensures that we can effortlessly organize and share the media files.

In this tutorial, we will show you how to quickly get a Plex server that runs on your local machine using the Docker containers and Docker Compose.

Requirements:

To run the commands and steps that are provided in this post, ensure that you have the following:

  1. Installed Docker Engine
  2. Installed Docker Compose
  3. Sufficient permissions to run the Docker containers

Define the Docker Compose File

The first step is defining the Docker compose configuration to run the Docker container. Start by creating the directory to store the config file:

$ mkdir plex

Navigate into the directory and create a file called “docker-compose.yml” file:

$ cd plex
$ touch docker-compose.yml

Edit the file and add the configuration as follows:

---
version: "2.1"
services:
  plex:
    image: lscr.io/linuxserver/plex:latest
    container_name: plex
    network_mode: host
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - VERSION=docker
      - PLEX_CLAIM= #optional
    volumes:
      - /path/to/library:/config
      - /path/to/tvseries:/tv
      - /path/to/movies:/movies
    restart: unless-stopped

The previous Docker compose file performs the following actions:

  1. Sets the Docker image as lscr.io/linuxserver/plex:latest
  2. Sets the name of the container to plex
  3. Uses the host network mode for optimal performance
  4. Sets the environment variables like PUID (User ID), PGID (Group ID), TZ (Timezone), VERSION, and an optional PLEX_CLAIM for Plex Pass
  5. Mounts the specific host directories (e.g., for media libraries, TV series, and movies) into the container
  6. Sets the restart policy for the container

To claim your token, head over to https://plex.tv/claim.

Run the Plex Container

Once we are satisfied with the configuration, we can use the Docker compose utility to run the container as follows:

$ docker compose up -d

You can access the Plex container from the specified address.

Conclusion

This basic tutorial covers the setup of a Plex server using the Docker containers and Docker Compose. Feel free to check the documentation to learn more about the configuration options.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list