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:
- Installed Docker Engine
- Installed Docker Compose
- 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:
Navigate into the directory and create a file called “docker-compose.yml” file:
$ 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:
- Sets the Docker image as lscr.io/linuxserver/plex:latest
- Sets the name of the container to plex
- Uses the host network mode for optimal performance
- Sets the environment variables like PUID (User ID), PGID (Group ID), TZ (Timezone), VERSION, and an optional PLEX_CLAIM for Plex Pass
- Mounts the specific host directories (e.g., for media libraries, TV series, and movies) into the container
- 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:
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.