### Setup QEMU for Cross-Architecture Builds Source: https://github.com/linuxserver/docker-plex/blob/master/README.md Installs and resets QEMU static binaries, which allows building ARM Docker images on x86_64 hardware and vice versa. This command requires privileged access. ```bash docker run --rm --privileged lscr.io/linuxserver/qemu-static --reset ``` -------------------------------- ### Nvidia Container Runtime Setup for Hardware Acceleration Source: https://github.com/linuxserver/docker-plex/blob/master/README.md For Nvidia GPUs, install the nvidia-container-toolkit on the host. Then, create the Docker container using the nvidia runtime and specify visible devices. ```bash --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all ``` -------------------------------- ### Package Installation Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/build-and-deployment.md Installs necessary packages, fetches the latest Plex Media Server version (or a specified release), installs the DEB package, and performs cleanup. ```dockerfile RUN apt-get update && \ apt-get install -y udev wget && \ # Fetch latest Plex version or use specified PLEX_RELEASE if [ -z ${PLEX_RELEASE+x} ]; then \ PLEX_RELEASE=$(curl -sX GET 'https://plex.tv/api/downloads/5.json' \ | jq -r '.computer.Linux.version'); \ fi && \ # Download and install Plex Media Server DEB curl -o /tmp/plexmediaserver.deb -L \ "${PLEX_DOWNLOAD}/${PLEX_RELEASE}/debian/plexmediaserver_${PLEX_RELEASE}_${PLEX_ARCH}.deb" && \ dpkg -i /tmp/plexmediaserver.deb && \ # Set abc user home directory usermod -d /app abc && \ # Cleanup apt-get clean && \ rm -rf /etc/default/plexmediaserver /tmp/* /var/lib/apt/lists/* /var/tmp/* ``` -------------------------------- ### Usage Patterns Documentation Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/INDEX.md Real-world examples and deployment scenarios, including complete examples and command sequences. ```markdown ### usage-patterns.md - **Best for:** Real-world examples - **Key sections:** Each deployment scenario - **Read time:** 35 minutes - **Contains:** Complete examples, command sequences, patterns ``` -------------------------------- ### Example User and Group ID Output Source: https://github.com/linuxserver/docker-plex/blob/master/README.md Example output from the 'id your_user' command, showing the UID and GID. ```text uid=1000(your_user) gid=1000(your_user) groups=1000(your_user) ``` -------------------------------- ### Docker Compose Configuration Example Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/configuration.md A comprehensive Docker Compose example demonstrating common configurations including network mode, environment variables, volume mounts, and hardware device mounting. ```yaml version: '3.8' services: plex: image: lscr.io/linuxserver/plex:latest container_name: plex network_mode: host environment: - PUID=1000 - PGID=1000 - TZ=America/New_York - VERSION=latest - PLEX_CLAIM=claim-xxxxx # Optional volumes: - /path/to/plex/config:/config - /path/to/tv:/tv - /path/to/movies:/movies - /run/plex-temp:/run/plex-temp:rw # For read-only mode devices: - /dev/dri:/dev/dri # For Intel QuickSync restart: unless-stopped ``` -------------------------------- ### Download and Install Plex Media Server Package Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/initialization-scripts.md Downloads a specific Plex Media Server .deb package and installs it using dpkg. The --force-confold option is used to preserve existing configuration files during the installation. ```bash wget -nv -P /tmp "${PLEX_DOWNLOAD}/${REMOTE_VERSION}/debian/plexmediaserver_${REMOTE_VERSION}_${PLEX_ARCH}.deb" dpkg -i --force-confold "/tmp/plexmediaserver_${REMOTE_VERSION}_${PLEX_ARCH}.deb" ``` -------------------------------- ### Example Debian Package Download URLs Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/api-endpoints.md Provides example URLs for downloading Plex Media Server Debian packages for different architectures. Replace {VERSION} with the specific release version. ```text https://downloads.plex.tv/plex-media-server-new/1.32.0.1192-ab5d2f5/debian/plexmediaserver_1.32.0.1192-ab5d2f5_amd64.deb ``` ```text https://downloads.plex.tv/plex-media-server-new/1.32.0.1192-ab5d2f5/debian/plexmediaserver_1.32.0.1192-ab5d2f5_arm64.deb ``` -------------------------------- ### Base Image Initialization Scripts Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Illustrates the execution of common initialization scripts from the base image for setup tasks. ```bash # Common initialization scripts /etc/s6-overlay/s6-rc.d/init-*/run ``` -------------------------------- ### Server Claiming API Response Example Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/api-endpoints.md Example XML response when successfully claiming a Plex server, containing the authentication token. ```xml 12345 user@example.com user@example.com ... ... true true https://plex.tv/users/... abc123def456ghi789 ... ... ... ``` -------------------------------- ### Check Package Installation Status Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Verify if a package is installed using dpkg and grep. The -w option ensures a whole-word match for 'install'. ```bash dpkg --get-selections plexmediaserver | grep -wq "install" ``` -------------------------------- ### Plex Media Server Installation Directory Structure Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/directory-structure.md Overview of the main executable, libraries, and resource files within the Plex Media Server installation directory. ```text plexmediaserver/ ├── Plex Media Server # Main executable ├── Plex DLNA Server # DLNA service executable ├── Plex Transcoder # Transcoding binary ├── start_pms # Startup wrapper script ├── lib/ # Shared libraries │ ├── libav*.so.* # FFmpeg libraries │ ├── libssl.so # OpenSSL │ └── [many runtime libs] ├── Resources/ # Application resources ├── plugins/ # Built-in plugins └── [various support files] ``` -------------------------------- ### Multi-stage Build Setup Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/build-and-deployment.md Sets up a multi-stage build by first extracting the unrar binary and then using the base Ubuntu image for the main application. ```dockerfile FROM ghcr.io/linuxserver/unrar:latest AS unrar FROM ghcr.io/linuxserver/baseimage-ubuntu:noble ``` -------------------------------- ### Plex API Response Example (XML) Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/api-endpoints.md Example XML response from the Plex API endpoint for personalized release details. Contains product name, version, distribution, build, and download URL. ```xml Plex Media Server 1.32.0.1192-ab5d2f5 debian linux-x86_64 https://downloads.plex.tv/plex-media-server-new/1.32.0.1192-ab5d2f5/debian/plexmediaserver_1.32.0.1192-ab5d2f5_amd64.deb ``` -------------------------------- ### Get Installed Plex Package Version with dpkg-query Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Queries the installed version of the 'plexmediaserver' package using dpkg-query with a custom output format. ```bash # Get installed version dpkg-query -W -f='${Version}' plexmediaserver ``` -------------------------------- ### Start Plex Service (Default/Root-Capable) Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/initialization-scripts.md Starts the Plex Media Server process using s6-setuidgid to run as the 'abc' user. It employs s6-notifyoncheck for service supervision and readiness checks on port 32400. ```bash exec s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost 32400" \ s6-setuidgid abc "/usr/lib/plexmediaserver/Plex Media Server" ``` -------------------------------- ### Container Labels Example Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/directory-structure.md Demonstrates how to set and access container labels in the Dockerfile and via the Docker inspect command. ```dockerfile LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="thelamer" ``` ```bash docker inspect -f '{{ index .Config.Labels "build_version" }}' ``` -------------------------------- ### Public Release Version JSON Response Example Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/api-endpoints.md Example JSON response from the public release version endpoint, detailing the latest version and beta status for different platforms. ```json { "computer": { "Linux": { "version": "1.32.0.1192-ab5d2f5", "installed": "0.9.12.4.1192-9a47d21", "beta": false, "requirements": "", "extra": "" } }, "android": { ... }, "ios": { ... }, ... } ``` -------------------------------- ### S6-Overlay Service 'run' Script Example Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/directory-structure.md This bash script demonstrates the basic structure for a service's executable logic within the s6-overlay system. It includes environment variable access. ```bash #!/usr/bin/with-contenv bash # Service implementation ``` -------------------------------- ### Check Installed Plex Version Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/initialization-scripts.md Queries the installed Plex Media Server version using dpkg-query. This is a prerequisite for checking if an update is needed. ```bash INSTALLED_VERSION=$(dpkg-query -W -f='${Version}' plexmediaserver) ``` -------------------------------- ### Build Plex Docker Image with Arguments Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/configuration.md Example of building the Plex Docker image using build-time arguments to specify the build date, image version, and Plex release version. ```bash docker build \ --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ --build-arg VERSION=v1.0 \ --build-arg PLEX_RELEASE=1.32.0.1192-ab5d2f5 \ -t lscr.io/linuxserver/plex:latest . ``` -------------------------------- ### S6-Overlay Service 'type' File Example Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/directory-structure.md This file defines the type of service managed by s6-overlay. It can be a 'oneshot' service that runs once at startup or a 'longrun' service that runs continuously. ```text oneshot # Runs once at startup and exits # or longrun # Runs continuously, supervised ``` -------------------------------- ### Start Plex Service (Non-Root) Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/initialization-scripts.md Starts the Plex Media Server process in a non-root user mode using s6-notifyoncheck. It monitors port 32400 for readiness and runs the Plex executable. ```bash exec s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost 32400" \ "/usr/lib/plexmediaserver/Plex Media Server" ``` -------------------------------- ### Docker Compose Path Mapping Example Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/directory-structure.md A Docker Compose configuration snippet demonstrating volume mappings for Plex data, media, and temporary directories. ```yaml volumes: - /mnt/plex-library:/config - /mnt/media/tv:/tv - /mnt/media/movies:/movies - /mnt/transcode-temp:/run/plex-temp:rw ``` -------------------------------- ### Basic Plex Deployment Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/usage-patterns.md Simplest deployment using host networking. Access Plex at http://:32400/web after starting. ```bash docker run -d \ --name=plex \ --net=host \ -v /path/to/library:/config \ lscr.io/linuxserver/plex:latest ``` -------------------------------- ### Install Plex DEB Package with dpkg Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Installs a local Plex Media Server DEB package, forcing the use of existing configuration files if conflicts arise during an upgrade. ```bash # Install package dpkg -i --force-confold /tmp/plexmediaserver.deb ``` -------------------------------- ### S6-Overlay Dependency Example Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/directory-structure.md This directory contains marker files that indicate service dependencies. The mere existence of a file named after another service signifies that the current service depends on it. ```text # Files named after service dependencies # File contents irrelevant; existence indicates dependency init-config # Depends on init-config service ``` -------------------------------- ### Install Plex Media Server Debian Package Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/api-endpoints.md Command to install the downloaded Plex Media Server Debian package using dpkg. Ensure the VERSION and PLEX_ARCH variables are set correctly. ```bash dpkg -i --force-confold /tmp/plexmediaserver_${VERSION}_${PLEX_ARCH}.deb ``` -------------------------------- ### Check if Plex Package is Installed with dpkg Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Checks if the 'plexmediaserver' package is currently installed on the system using dpkg's selection query. ```bash # Check if package is installed dpkg --get-selections plexmediaserver | grep -wq "install" ``` -------------------------------- ### GPU Support Setup Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/build-and-deployment.md Enables NVIDIA GPU support for hardware video transcoding by setting the NVIDIA_DRIVER_CAPABILITIES environment variable. ```dockerfile ENV NVIDIA_DRIVER_CAPABILITIES="compute,video,utility,graphics" ``` -------------------------------- ### Bash Regex Example with Captured Directory Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md An example script snippet showing how to extract a directory path from a line using bash regex and check if it exists. ```bash TranscoderTempDirectory='\bTranscoderTempDirectory="([^"]+)"' if [[ ${line} =~ ${TranscoderTempDirectory} ]] && [[ -d "${BASH_REMATCH[1]}" ]]; then echo "Found: ${BASH_REMATCH[1]}" fi ``` -------------------------------- ### S6-Overlay Service 'up' File Example Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/directory-structure.md The 'up' file specifies the completion or readiness condition for a service. For 'oneshot' services, it indicates when the task is complete. For 'longrun' services, it signifies when the service is ready to accept connections or perform its function. ```text # For oneshot services: indicates completion condition # For longrun services: readiness condition ``` -------------------------------- ### Shell Functions and Utilities Documentation Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/INDEX.md Resources for script debugging and understanding, featuring function signatures and usage examples. ```markdown ### shell-functions-and-utilities.md - **Best for:** Script debugging and understanding - **Key sections:** Each utility, usage examples - **Read time:** 30 minutes - **Contains:** Function signatures, examples, explanations ``` -------------------------------- ### Parse Changelog Entry Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/build-and-deployment.md Example of a changelog entry format used in `readme-vars.yml`. It includes the date and a description of the change. ```yaml changelogs: - {date: "15.03.26:", desc: "Allow TMPDIR to be changed..."} - {date: "04.11.24:", desc: "Add Nvidia capability..."} ``` -------------------------------- ### Plex Installation Directory Ownership Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/directory-structure.md Specifies the owner and permissions for the main Plex Media Server installation directory, typically managed by root. ```text /usr/lib/plexmediaserver/ owner: root:root /usr/lib/plexmediaserver/Plex Media Server owner: root:root, mode: 755 ``` -------------------------------- ### GET /plex-media-server-new/{VERSION}/debian/plexmediaserver_{VERSION}_{PLEX_ARCH}.deb Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/api-endpoints.md Downloads the Plex Media Server Debian package for a specific version and architecture. No authentication is required. ```APIDOC ## GET https://downloads.plex.tv/plex-media-server-new/{VERSION}/debian/plexmediaserver_{VERSION}_{PLEX_ARCH}.deb ### Description Downloads Plex Media Server Debian package. ### Method GET ### Endpoint https://downloads.plex.tv/plex-media-server-new/{VERSION}/debian/plexmediaserver_{VERSION}_{PLEX_ARCH}.deb ### Parameters #### Path Parameters - **VERSION** (string) - Required - Release version string (e.g., `1.32.0.1192-ab5d2f5`) - **PLEX_ARCH** (string) - Required - CPU architecture (`amd64`, `arm64`, or `armhf`) ### Response #### Success Response (200) - Binary (Debian package file) ### Response Example (Binary file content for the Debian package) ### Installation Command ```bash dpkg -i --force-confold /tmp/plexmediaserver_${VERSION}_${PLEX_ARCH}.deb ``` ``` -------------------------------- ### Docker CLI Command for Plex Setup Source: https://github.com/linuxserver/docker-plex/blob/master/README.md This Docker CLI command deploys a Plex container with specified environment variables, volume mounts for configuration and media, and restart policy. Remember to replace placeholder paths with your actual host paths. ```bash docker run -d \ --name=plex \ --net=host \ -e PUID=1000 \ -e PGID=1000 \ -e TZ=Etc/UTC \ -e VERSION=docker \ -e PLEX_CLAIM= `#optional` \ -v /path/to/plex/library:/config \ -v /path/to/tvseries:/tv \ -v /path/to/movies:/movies \ --restart unless-stopped \ lscr.io/linuxserver/plex:latest ``` -------------------------------- ### Bash While Loop Examples Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Demonstrates two common 'while' loop patterns: an indefinite loop that runs until explicitly broken, and a loop that continues as long as a specific process ID is running. ```bash while true; do # Loop indefinitely until break done while ps -p $PID >/dev/null; do sleep 1 done ``` -------------------------------- ### Get System Architecture with uname Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Retrieves the machine hardware name, which indicates the system architecture (e.g., x86_64, aarch64). ```bash # Get architecture PLEX_MEDIA_SERVER_INFO_MODEL=$(uname -m) # Output: x86_64, aarch64, armv7l, etc. ``` -------------------------------- ### Update All Docker Compose Containers Source: https://github.com/linuxserver/docker-plex/blob/master/README.md Recreate and start all containers defined in the docker-compose.yml file to use the updated images. ```bash docker-compose up -d ``` -------------------------------- ### Plex Hardware Acceleration with NVIDIA GPU Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/usage-patterns.md Configures Plex for NVIDIA GPUs using the nvidia-docker runtime. Requires nvidia-docker2 installed on the host. Can specify all devices or by UUID. ```bash # Install nvidia-docker2 on host first # See: https://github.com/NVIDIA/nvidia-docker docker run -d \ --name=plex \ --net=host \ --runtime=nvidia \ -e NVIDIA_VISIBLE_DEVICES=all \ -v /path/to/library:/config \ lscr.io/linuxserver/plex:latest ``` ```bash nvidia-smi --query-gpu=gpu_name,gpu_uuid --format=csv ``` -------------------------------- ### Standard Production Docker Compose Deployment for Plex Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/usage-patterns.md A standard Docker Compose setup for Plex, including PUID, PGID, TZ, VERSION, PLEX_CLAIM, volume mounts for config and media, and device mapping for Intel QuickSync. ```yaml version: '3.8' services: plex: image: lscr.io/linuxserver/plex:latest container_name: plex network_mode: host environment: - PUID=1000 - PGID=1000 - TZ=America/New_York - VERSION=latest - PLEX_CLAIM=claim-xxxxxxxxxx volumes: - /mnt/storage/plex/config:/config - /mnt/storage/plex/transcode:/run/plex-temp - /media/tv:/tv - /media/movies:/movies - /media/music:/music restart: unless-stopped devices: - /dev/dri:/dev/dri # Intel QuickSync ``` -------------------------------- ### Get User and Group IDs Source: https://github.com/linuxserver/docker-plex/blob/master/README.md Use the 'id' command to find the user and group IDs on the host system, which should match the PUID and PGID set for the container to avoid volume permission issues. ```bash id your_user ``` -------------------------------- ### Initialization Scripts Documentation Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/INDEX.md Details on understanding startup behavior and execution order of initialization scripts. ```markdown ### initialization-scripts.md - **Best for:** Understanding startup behavior - **Key sections:** Each script individually, execution order - **Read time:** 25 minutes - **Contains:** Code snippets, detailed explanations, error handling ``` -------------------------------- ### Plex Docker Deployment with Auto-Claiming Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/README.md Deploy Plex Media Server with auto-claiming enabled using a Plex claim token. This is useful for initial server setup, especially with bridge networking. ```bash # Get token from https://plex.tv/claim (expires in 4 minutes) docker run -d \ --name=plex \ --net=host \ -e PUID=1000 \ -e PGID=1000 \ -e PLEX_CLAIM=claim-xxxxxxxxxx \ -e VERSION=latest \ -v /path/to/plex/library:/config \ -v /path/to/media:/tv \ lscr.io/linuxserver/plex:latest ``` -------------------------------- ### GET /downloads/details/5 Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/api-endpoints.md Retrieves personalized Plex Media Server version information based on user's PlexPass status and selected channel. Requires authentication via X-Plex-Token header. ```APIDOC ## GET https://plex.tv/downloads/details/5 ### Description Retrieves personalized version information based on user's PlexPass status and selected channel. ### Method GET ### Endpoint https://plex.tv/downloads/details/5 ### Parameters #### Query Parameters - **distro** (string) - Required - Package distribution (e.g., `debian`) - **build** (string) - Required - Build/architecture variant (`linux-x86_64`, `linux-aarch64`, or `linux-armv7hf_neon`) - **channel** (integer) - Required - Release channel (e.g., `8` for latest) - **X-Plex-Token** (string) - Required - User authentication token ### Request Headers - **X-Plex-Token**: User's PlexOnlineToken ### Response #### Success Response (200) - **version** (string) - Latest version available to user - **url** (string) - Download URL ### Response Example ```xml Plex Media Server 1.32.0.1192-ab5d2f5 debian linux-x86_64 https://downloads.plex.tv/plex-media-server-new/1.32.0.1192-ab5d2f5/debian/plexmediaserver_1.32.0.1192-ab5d2f5_amd64.deb ``` ### Example Usage ```bash curl -s "https://plex.tv/downloads/details/5?distro=debian&build=linux-x86_64&channel=8&X-Plex-Token=abc123" \ | grep -oP 'version=\"\K[^\"]+' ``` ``` -------------------------------- ### Build and Deployment Documentation Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/INDEX.md Information for building and deploying the Docker image, including Dockerfile analysis and build commands. ```markdown ### build-and-deployment.md - **Best for:** Building and deploying - **Key sections:** Dockerfile analysis, build commands, registries - **Read time:** 25 minutes - **Contains:** Build examples, layer analysis, registry info ``` -------------------------------- ### Add Device for Hardware Acceleration or DVB Source: https://github.com/linuxserver/docker-plex/blob/master/README.md Map host devices to the container for hardware acceleration (e.g., Quicksync) or DVB devices. ```bash --device=/dev/dri:/dev/dri ``` ```bash --device=/dev/dvb:/dev/dvb ``` -------------------------------- ### Get Kernel Release Version with uname Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Retrieves the kernel release version of the system. ```bash # Get kernel version PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION=$(uname -r) # Output: 5.10.0-1-generic, etc. ``` -------------------------------- ### Standard Host-to-Container Path Mapping Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/directory-structure.md Illustrates a typical mapping of host directories to container directories for Plex configuration, media, and temporary files. ```text Host Container /mnt/plex-library → /config /mnt/media/tv → /tv /mnt/media/movies → /movies /mnt/transcode-temp → /run/plex-temp /etc/localtime → /etc/localtime:ro (for TZ sync) ``` -------------------------------- ### Metadata for Library Items Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/api-endpoints.md Gets detailed metadata for a specific item within a library, identified by its ID. ```APIDOC ## GET /library/metadata/{id} ### Description Retrieves metadata for a specific library item using its ID. ### Method GET ### Endpoint /library/metadata/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the library item. ``` -------------------------------- ### Basic Plex Docker Deployment Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/README.md Deploy Plex Media Server with essential configurations. Ensure the host network is used for accessibility and map your Plex library and media directories. ```bash docker run -d \ --name=plex \ --net=host \ -e PUID=1000 \ -e PGID=1000 \ -v /path/to/plex/library:/config \ -v /path/to/media:/tv \ lscr.io/linuxserver/plex:latest ``` -------------------------------- ### Update Specific Docker Compose Container Source: https://github.com/linuxserver/docker-plex/blob/master/README.md Recreate and start a single container, 'plex', defined in the docker-compose.yml file. ```bash docker-compose up -d plex ``` -------------------------------- ### File Organization Structure Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/README.md Illustrates the directory structure for the Plex Docker project documentation files. ```bash /workspace/home/output/ ├── README.md (this file) ├── overview.md (project overview) ├── configuration.md (config reference) ├── initialization-scripts.md (startup scripts) ├── api-endpoints.md (Plex API reference) ├── directory-structure.md (filesystem layout) ├── shell-functions-and-utilities.md (utility functions) ├── build-and-deployment.md (build process) └── usage-patterns.md (practical examples) ``` -------------------------------- ### Environment Files Created During Startup Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/directory-structure.md Lists temporary files created during container startup to indicate specific conditions like missing version information or authentication tokens. ```text /tmp/no-version.nfo # Message if VERSION not set /tmp/update_fail.nfo # Message if update fails /tmp/no-token.nfo # Message if auth token missing ``` -------------------------------- ### Completeness Checklist Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/INDEX.md A checklist indicating the completeness of the documentation for various aspects of the Docker Plex image. ```markdown ## Completeness Checklist - ✅ All initialization scripts documented - ✅ All configuration options listed - ✅ All API endpoints described - ✅ All exposed ports documented - ✅ All volume mount points listed - ✅ All environment variables documented - ✅ Build process documented - ✅ Deployment methods covered - ✅ Practical examples provided - ✅ Troubleshooting guide included - ✅ Hardware acceleration documented - ✅ Multi-architecture support explained - ✅ CI/CD pipeline documented - ✅ Quick start provided - ✅ Navigation hub created ``` -------------------------------- ### Plex Deployment with Multiple Media Volumes Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/usage-patterns.md Mounts multiple directories for different media types (TV, movies, music, photos). Inside Plex, add library sections for each mounted path independently. ```bash docker run -d \ --name=plex \ --net=host \ -v /path/to/library:/config \ -v /mnt/media/tv:/tv \ -v /mnt/media/movies:/movies \ -v /mnt/media/music:/music \ -v /mnt/media/photos:/photos \ lscr.io/linuxserver/plex:latest ``` -------------------------------- ### Extract Regex Group with Sed Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Extract a specific value captured by a regex group using sed. This example targets the ProcessedMachineIdentifier. ```bash sed -n "s/^.*ProcessedMachineIdentifier=\"\([^\"*]\)\".*$/\1/p" ``` -------------------------------- ### Directory Structure Documentation Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/INDEX.md Guidance for finding files and understanding the layout, including directory trees and permission specifications. ```markdown ### directory-structure.md - **Best for:** Finding files and understanding layout - **Key sections:** Directory trees, file ownership, paths - **Read time:** 20 minutes - **Contains:** Directory listings, permission specs, examples ``` -------------------------------- ### Extract Value from XML Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Extract a specific value, like a token, from an XML file using sed. This example targets the PlexOnlineToken. ```bash sed -n 's/.*PlexOnlineToken="//p' "${FILE}" | sed 's/"..*/' ``` -------------------------------- ### Build Docker Image for x86-64 Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/build-and-deployment.md Builds the Docker image for the x86-64 architecture. Use `--no-cache` to build from scratch and `--pull` to always pull base images. Pass build arguments like BUILD_DATE, VERSION, and PLEX_RELEASE. ```bash docker build \ --no-cache \ --pull \ --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ --build-arg VERSION=1.0.0-ls1 \ --build-arg PLEX_RELEASE=1.32.0.1192-ab5d2f5 \ -t lscr.io/linuxserver/plex:latest . ``` -------------------------------- ### Debian Package Downloads Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/MANIFEST.md Endpoints for downloading Debian packages of Plex Media Server. These are typically used for direct installation on Debian-based systems. ```APIDOC ## Debian package download endpoints ### Description Provides access to download Plex Media Server as Debian packages. ### Method GET (implied) ### Endpoint (Specific endpoints not detailed in source, but implied) ### Parameters ### Request Body ### Request Example ### Response #### Success Response (200) #### Response Example ``` -------------------------------- ### Backup Plex Configuration Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/usage-patterns.md Commands to create a compressed backup of the Plex configuration directory and restore it if necessary. Use this before performing updates or major changes. ```bash # Create backup docker exec plex tar czf - /config | gzip > plex-backup-$(date +%Y%m%d).tar.gz # Restore if needed docker exec -i plex tar xzf - < plex-backup-20240315.tar.gz ``` -------------------------------- ### Build and Run Air-Gapped Plex Container Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/usage-patterns.md Builds a Plex Docker image for air-gapped environments using a specific Plex release and runs it without update checks. This is for environments lacking internet access. ```bash # Build with specific Plex version known to work docker build \ --build-arg PLEX_RELEASE=1.32.0.1192-ab5d2f5 \ --no-cache \ -t plex:air-gapped . # Run without VERSION setting (no update checks) docker run -d \ --name=plex \ --net=host \ -e ADVANCED_DISABLEUPDATES=1 \ -v /path/to/library:/config \ plex:air-gapped ``` -------------------------------- ### Bash Until Loop Example Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md An 'until' loop construct that repeatedly executes a block of code until a specified condition evaluates to true. Commonly used in readiness checks. ```bash until [[ condition ]]; do echo "Waiting..." sleep 1 done ``` -------------------------------- ### Remove Prefix from String in Bash Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Removes the shortest matching prefix pattern from a string, for example, removing characters up to and including the first colon using `${VAR#*:}`. ```bash # Everything after colon "${VAR#*:}" ``` -------------------------------- ### Run Service with Readiness Check Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Execute a service command and notify s6-rc of readiness once a check command succeeds. Includes options for daemonization, timeouts, and check intervals. ```bash s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost 32400" \ s6-setuidgid abc "/usr/lib/plexmediaserver/Plex Media Server" ``` -------------------------------- ### Sourcing Container Environment Variables Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Shows how to source container environment variables using the provided container-env.sh script. ```bash # Source container environment variables . /etc/profile.d/container-env.sh ``` -------------------------------- ### Bridge Network Mode Port Mappings Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/configuration.md For bridge network mode, explicit port mappings are required for Plex to be accessible. This example shows the default TCP and UDP ports. ```bash docker run -d \ -p 32400:32400/tcp \ -p 1900:1900/udp \ -p 5353:5353/udp \ -p 8324:8324/tcp \ -p 32410:32410/udp \ -p 32412:32412/udp \ -p 32413:32413/udp \ -p 32414:32414/udp \ -p 32469:32469/tcp ``` -------------------------------- ### Build Plex Docker Image for x86-64 Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/overview.md Use this command to build the Plex Docker image for x86-64 architecture. Ensure you are in the directory containing the Dockerfile. ```bash docker build --no-cache --pull \ -t lscr.io/linuxserver/plex:latest . ``` -------------------------------- ### Terminate Plex Process with kill Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Sends a termination signal to a specific process ID (PID), typically used to stop the Plex Media Server after its initial setup or when required. ```bash # Terminate Plex after initial startup kill $PID ``` -------------------------------- ### Plex Hardware Acceleration with Intel QuickSync Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/usage-patterns.md Enables hardware video decoding and encoding on Intel CPUs by exposing the DRI devices. Verify usage in Plex Settings. ```bash docker run -d \ --name=plex \ --net=host \ --device=/dev/dri:/dev/dri \ -v /path/to/library:/config \ lscr.io/linuxserver/plex:latest ``` -------------------------------- ### Plex Multi-Container Service Stack Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/usage-patterns.md Defines a Docker Compose stack for Plex, Prometheus monitoring, and a backup service. This setup allows for integrated management of Plex and its related services. ```yaml version: '3.8' services: plex: image: lscr.io/linuxserver/plex:latest container_name: plex network_mode: host environment: - PUID=1000 - PGID=1000 - VERSION=latest volumes: - plex-config:/config - media:/media restart: unless-stopped prometheus: image: prom/prometheus container_name: prometheus ports: - "9090:9090" volumes: - prometheus:/prometheus restart: unless-stopped backup: image: alpine container_name: plex-backup command: > sh -c "while true; do tar czf /backups/plex-$(date +%Y%m%d).tar.gz /config; sleep 86400; done" volumes: - plex-config:/config:ro - /backup/location:/backups restart: unless-stopped volumes: plex-config: prometheus: networks: default: name: media-stack ``` -------------------------------- ### Configure NVIDIA GPU for Hardware Acceleration Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/configuration.md To use NVIDIA GPUs for hardware acceleration, install nvidia-docker2 and specify the NVIDIA runtime. You can expose all GPUs or specific ones using their UUID. ```bash docker run --runtime=nvidia \ -e NVIDIA_VISIBLE_DEVICES=all ``` ```bash -e NVIDIA_VISIBLE_DEVICES= ``` ```bash nvidia-smi --query-gpu=gpu_name,gpu_uuid --format=csv ``` -------------------------------- ### Build with Auto-detected Plex Version Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/build-and-deployment.md Builds the Docker image with the Plex Media Server version automatically detected from the Plex API. ```bash docker build -t plex:latest . ``` -------------------------------- ### Run Plex Container with Latest Version Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/usage-patterns.md This command deploys the Plex container, ensuring it stays on the latest available release. Updates are applied by restarting the container after logging in via the web UI. ```bash docker run -d \ --name=plex \ --net=host \ -e VERSION=latest \ -v /path/to/library:/config \ lscr.io/linuxserver/plex:latest ``` -------------------------------- ### Run Plex with Raspberry Pi 4 Hardware Acceleration Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/usage-patterns.md Enable hardware acceleration on Raspberry Pi 4 by mounting the DRI devices. Ensure the 'vc4-fkms-v3d' overlay is enabled in /boot/usercfg.txt. ```bash # In /boot/usercfg.txt on Pi host dtoverlay=vc4-fkms-v3d docker run -d \ --name=plex \ --net=host \ --device=/dev/dri:/dev/dri \ -v /path/to/library:/config \ lscr.io/linuxserver/plex:latest ``` -------------------------------- ### Get File Owner UID with stat Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Retrieves the numeric UID of the file owner using the stat command. This is used to check for changes in file ownership, such as for the Plex configuration directory. ```bash # Check PUID change stat -c %u /config/Library ``` -------------------------------- ### Get Personalized Plex Release Version Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/api-endpoints.md Retrieves personalized version information based on user's PlexPass status and selected channel. Requires authentication via X-Plex-Token header. ```bash curl -s "https://plex.tv/downloads/details/5?distro=debian&build=linux-x86_64&channel=8&X-Plex-Token=abc123" \ | grep -oP 'version="\K[^" ]+' ``` -------------------------------- ### Build Plex Docker Image Locally Source: https://github.com/linuxserver/docker-plex/blob/master/README.md Builds the Plex Docker image from the local source code. Use --no-cache to ensure a clean build and --pull to fetch base images. ```bash docker build \ --no-cache \ --pull \ -t lscr.io/linuxserver/plex:latest . ``` -------------------------------- ### Build Plex Docker Image for ARM64 Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/overview.md Use this command to build the Plex Docker image specifically for ARM64 architecture. This requires specifying a different Dockerfile. ```bash docker build --no-cache --pull \ -f Dockerfile.aarch64 \ -t lscr.io/linuxserver/plex:arm64v8-latest . ``` -------------------------------- ### Clean Up Old Plex Packages Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/usage-patterns.md Remove old Plex DEB files from the container's temporary directory. This is useful if you are using a volume for configuration and want to clean up temporary installation files. ```bash # Remove old Plex DEB files from temp docker exec plex rm -f /tmp/plexmediaserver_*.deb ``` -------------------------------- ### Get File Size with stat Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Retrieves the file size in bytes for a given file using the stat command. This is used for validation, such as checking if a DEB package meets a minimum size requirement. ```bash # Check file size (minimum 10KB for DEB validation) stat -c %s "/tmp/plexmediaserver_${REMOTE_VERSION}_${PLEX_ARCH}.deb" ``` -------------------------------- ### Build Multi-Architecture Image with Buildx Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/build-and-deployment.md Builds and pushes a multi-architecture Docker image using Docker Buildx, supporting both linux/amd64 and linux/arm64 platforms. Tags the image as latest. ```bash docker buildx build \ --platform linux/amd64,linux/arm64 \ --push \ -t lscr.io/linuxserver/plex:latest . ``` -------------------------------- ### Docker Compose Deployment with Nginx Reverse Proxy Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/usage-patterns.md Deploy Plex with an Nginx reverse proxy using Docker Compose. This setup includes configurations for ports, volumes, and dependencies between Plex and Nginx services. ```yaml version: '3.8' services: plex: image: lscr.io/linuxserver/plex:latest container_name: plex network_mode: host environment: - PUID=1000 - PGID=1000 - TZ=America/New_York - VERSION=docker - PLEX_CLAIM=claim-xxxxxxxxxx volumes: - /mnt/plex/config:/config - /media:/media restart: unless-stopped nginx: image: nginx:alpine container_name: nginx ports: - "80:80" - "443:443" volumes: - /etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro - /etc/letsencrypt:/etc/letsencrypt:ro - /var/www/certbot:/var/www/certbot:ro depends_on: - plex restart: unless-stopped ``` -------------------------------- ### Local Docker Build and Run for Plex Testing Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/build-and-deployment.md Commands to build the Plex Docker image locally and run a test container. This is useful for development and debugging. ```bash # Build locally docker build -t plex:test . # Run test container docker run -it --rm \ -v /tmp/plex:/config \ -e PUID=1000 \ -e PGID=1000 \ plex:test # Check logs docker logs plex ``` -------------------------------- ### Local Files and Utilities Copy Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/build-and-deployment.md Copies s6-overlay configuration and the unrar binary from other stages or local directories into the image. ```dockerfile COPY root/ / COPY --from=unrar /usr/bin/unrar-ubuntu /usr/bin/unrar ``` -------------------------------- ### Run Plex with CPU Limiting Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/usage-patterns.md Launches the Plex container and limits its CPU usage to 2 cores. This prevents Plex from consuming all available CPU resources during transcoding operations. ```bash docker run -d \ --name=plex \ --net=host \ --cpus="2" \ -v /path/to/library:/config \ lscr.io/linuxserver/plex:latest ``` -------------------------------- ### Plex Download URL Differences by Architecture Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/directory-structure.md Explains how the download query parameters for Plex differ based on the target architecture (amd64, arm64, armhf). ```text -amd64: `linux-x86_64` in API queries - arm64: `linux-aarch64` in API queries - armhf (deprecated): `linux-armv7hf_neon` in API queries ``` -------------------------------- ### Automatically Claim Plex Media Server Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/initialization-scripts.md This script automatically claims the Plex Media Server using a claim token. It handles initial Plex startup for configuration generation, token exchange with Plex.tv, and updates the Preferences.xml file with the obtained token. ```bash # Initial config generation s6-setuidgid abc /bin/bash -c \ 'LD_LIBRARY_PATH=/usr/lib/plexmediaserver:/usr/lib/plexmediaserver/lib /usr/lib/plexmediaserver/Plex\ Media\ Server' # Token exchange curl -X POST \ -H 'X-Plex-Client-Identifier: ' ``` ```bash "${ProcessedMachineIdentifier}" \ "https://plex.tv/api/claim/exchange?token=${PLEX_CLAIM}" # Update preferences sed -i "s/"/>/ PlexOnlineToken="${PlexOnlineToken}"">/g" "${PLEX_MEDIA_SERVER_PREFERENCES}" ``` -------------------------------- ### Pull Docker Image for Specific Architecture Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/build-and-deployment.md Demonstrates how to pull Docker images, either automatically selecting the correct architecture for multi-arch manifests or explicitly pulling for a specific architecture like amd64 or arm64v8. ```bash # Pull automatically gets correct architecture docker pull lscr.io/linuxserver/plex:latest # Or explicitly pull specific architecture docker pull lscr.io/linuxserver/plex:amd64-latest docker pull lscr.io/linuxserver/plex:arm64v8-latest ``` -------------------------------- ### Plex Preferences File Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/directory-structure.md The Preferences.xml file contains crucial server settings, authentication tokens, and library configurations. It resides within the Plex Media Server configuration directory. ```text /config/Library/Application Support/Plex Media Server/Preferences.xml ``` -------------------------------- ### Enable Read-Only Filesystem Mode Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/configuration.md Run the container with a read-only filesystem for increased security. This requires the transcode directory to be mounted to a writable location like tmpfs or a host path. ```bash --read-only=true ``` ```bash --tmpfs /run/plex-temp:size=10G ``` -------------------------------- ### Plex Deployment with Version Control Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/usage-patterns.md Enables automatic updates to the latest version. Restart the container after the first login to apply updates. ```bash docker run -d \ --name=plex \ --net=host \ -e VERSION=latest \ -v /path/to/library:/config \ lscr.io/linuxserver/plex:latest ``` ```bash docker restart plex ``` -------------------------------- ### Bash Here-Document for File Output Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/shell-functions-and-utilities.md Demonstrates using a here-document with a custom marker to write multi-line content to a file, allowing for indented markers. ```bash cat >"${FILE}" <<-EOFMARKER Line 1 Line 2 EOFMARKER ``` -------------------------------- ### Run Plex with NVIDIA GPU Acceleration Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/usage-patterns.md Use this command to run the Plex container with NVIDIA GPU acceleration, specifying the visible devices. ```bash docker run -d \ --name=plex \ --net=host \ --runtime=nvidia \ -e NVIDIA_VISIBLE_DEVICES=00000000-1111-2222-3333-444444444444 \ -v /path/to/library:/config \ lscr.io/linuxserver/plex:latest ``` -------------------------------- ### Run Plex with Increased Memory Allocation Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/usage-patterns.md Launches the Plex container with a memory limit of 4GB. This is recommended for large libraries (1000+ items) to ensure sufficient memory for Plex's operations. ```bash docker run -d \ --name=plex \ --net=host \ -m 4g \ --memory-swap 4g \ -v /path/to/library:/config \ lscr.io/linuxserver/plex:latest ``` -------------------------------- ### Build Docker Image for ARM64 Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/build-and-deployment.md Builds the Docker image specifically for the ARM64 architecture using the Dockerfile.aarch64. Includes build arguments for date and version. ```bash docker build \ --no-cache \ --pull \ -f Dockerfile.aarch64 \ --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ --build-arg VERSION=1.0.0-ls1 \ -t lscr.io/linuxserver/plex:arm64v8-latest . ``` -------------------------------- ### Build with Specific Plex Version Source: https://github.com/linuxserver/docker-plex/blob/master/_autodocs/build-and-deployment.md Builds the Docker image using a specific Plex Media Server release version specified via the --build-arg flag. ```bash docker build \ --build-arg PLEX_RELEASE=1.32.0.1192-ab5d2f5 \ -t plex:latest . ```