Plex

Introduction

Plex Media Server is a software application that allows you to organize and stream your collection of movies, TV shows, music, and photos, from a central location. Think of it like having your own personal Netflix or Spotify server that you can access from various devices. It's a great tool for anyone who wants to streamline their media consumption and take control of their entertainment experience.

The Docker Compose File

---
version: "3.8"

services:
  plex:
    image: plexinc/pms-docker:latest
    container_name: plex
    hostname: plex
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    env_file:
      - .env
    environment:
      - TZ=${TZ}
      - PUID=${PUID}
      - PGID=${PGID}
      - VERSION=${VERSION}
      - PLEX_CLAIM=${PLEX_CLAIM}
    ports:
      - 32400:32400
    volumes:
      - /opt/plex/config:/config
      - /opt/plex/transcode:/transcode
      - /data/media:/data/media
      - /etc/localtime:/etc/localtime:ro
    labels:
      - com.centurylinklabs.watchtower.enable=true

docker-compose.yml

The Docker Environment Variables File

TZ=Europe/Stockholm
PUID=1000
PGID=1000
VERSION=docker
PLEX_CLAIM=***********

.env

This Docker Compose file defines a single service named “plex”. The service is built from the “plexinc/pms-docker:latest” Docker image, which is the latest version available. The container name is set to “plex” as well.

The “restart” section ensures that the container will always be restarted if it exits (unless manually stopped). This is useful for ensuring that the service is always available, especially if it crashes or is shut down unexpectedly.

The “security_opt” section prevents your container processes from gaining additional privileges. This is an important security consideration.

The “ports” section maps port 32400 on the host machine to port 32400 in the container. This allows us to access the Plex web interface from our local machine.

The “volumes” section maps the “/config” directory inside the container to a local directory on the host machine. This allows us to persist data across container restarts. Plex stores all its configuration and monitoring data in this directory, so it’s important to keep it intact. We also map the locations of our media directory to /data/media.

The "labels" section allows the Watchtower service to keep this container update automatically.

Running Plex with Docker Compose

To run Plex with Docker Compose, first, make sure you have Docker and Docker Compose installed on your machine. Then, create a new directory for your Plex project and save the above Docker Compose file as “docker-compose.yml” in that directory.

Next, run the following command from the same directory:

docker compose up -d

This command will start the home-assistant container in the background and detach from it. You can then access the Plex web interface by going to http://localhost:32400 in your web browser.

Conclusion

In this article, we explored how to set up and run the Plex software using Docker Compose. We looked at the different sections of the Docker Compose file and explained how they work together to create a functional Plex service. By running Plex with Docker Compose, you can easily deploy and manage the tool on your own server, without having to worry about dependencies or configuration.


Meet your TV concierge.
Enjoy all of your entertainment, no matter where it lives, plus 50,000+ free titles from us.