Can you make me a docker compose yml for deploying Plex, not from plex.tv, but from…
- User
Can you make me a docker compose yml for deploying Plex, not from plex.tv, but from linuxserver.io?
- Assistant
Can you make me a docker compose yml for deploying Plex, not from plex.tv, but from linuxserver.io?
Certainly! Below is a docker-compose.yml file tailored for deploying Plex Media Server using the LinuxServer.io Docker image. This configuration sets up Plex with persistent storage, necessary environment variables, and appropriate network settings.
docker-compose.ymlversion: '3.8'
services:
plex:
image: linuxserver/plex:latest
container_name: plex
restart: unless-stopped
network_mode: bridge
ports:
- "32400:32400/tcp" # Plex Web Interface
- "3005:3005/tcp" # Plex Announcement
- "8324:8324/tcp" # Plex Companion
- "32469:32469/tcp" # Plex DLNA
- "32410:32410/udp" # Plex DLNA
- "32412:32412/udp" # Plex DLNA
- "32413:32413/udp" # Plex DLNA
- "32414:32414/udp" # Plex DLNA
environment:
- PUID=1000 # User ID (change to your user's UID)
- PGID=1000 # Group ID (change to your user's GID)
- VERSION=docker # Plex version (use 'latest' or specify a version)
- TZ=Etc/UTC # Timezone (e.g., America/New_York)
# Optional: Uncomment and set if you have a license file
# - PLEX_CLAIM=claim-code
volumes:
- /path/to/config:/config # Configuration files
- /path/to/tvseries:/tv # TV series media
- /path/to/movies:/movies # Movies media
- /path/to/transcode:/transcode # Temporary transcode storage
devices:
- /dev/dri:/dev/dri # GPU hardware acceleration (optional)
# Optional: If you want to use host networking instead
# network_mode: host
Version:
version: '3.8': Specifies the Docker Compose file format version.Services:
Image:
image: linuxserver/plex:latest: Uses the latest Plex image from LinuxServer.io. You can specify a particular version if needed.Container Name:
container_name: plex: Names the container plex for easy reference.Restart Policy:
restart: unless-stopped: Ensures the Plex container restarts automatically unless it’s explicitly stopped.Network Mode:
network_mode: bridge: Uses Docker's default bridge network. Alternatively, you can use host networking by uncommenting the network_mode: host line, which can simplify port configurations but has different security implications.Ports:
32400 is essential for the web interface, but additional ports are mapped for various Plex services like DLNA and announcements.host networking, you can omit the ports section.Environment Variables:
PUID=1000 and PGID=1000: Set the user and group IDs to match your host system's user. This ensures proper permissions for file access. You can find your UID and GID using id username on Linux.VERSION=docker: Specifies the version of Plex. Typically set to docker for the latest version.TZ=Etc/UTC: Sets the timezone. Replace Etc/UTC with your local timezone (e.g., America/New_York).PLEX_CLAIM: Optional. If you have a Plex claim token, you can add it here to automatically claim your server. Obtain a claim token from Plex's claim page.Volumes:
Install Docker and Docker Compose:
Create the docker-compose.yml File:
~/docker/plex/.docker-compose.yml and paste the above configuration into it.Configure Volumes and Environment Variables:
/path/to/config, /path/to/tvseries, /path/to/movies, and /path/to/transcode with actual paths on your host system.PUID and PGID to match your user's UID and GID. You can find these by running:
id yourusername
TZ variable to your local timezone. For example, America/New_York.(Optional) Set Up Hardware Acceleration:
devices section accordingly.Start the Plex Container:
cd ~/docker/plex/
docker-compose up -d
-d flag runs the container in detached mode.Access Plex Web Interface:
http://your-server-ip:32400/web.Updating Plex:
docker-compose pull
docker-compose up -d
Managing Permissions:
/path/to/config, /path/to/tvseries) have the appropriate permissions so that the Docker container can read and write to them.Logging:
docker-compose logs -f plex
Backup:
/config volume to save your Plex settings and library metadata.Environment Variables:
Assuming you choose /srv/docker/plex as your Docker Compose directory, your directory structure might look like this:
/srv/docker/plex/
├── docker-compose.yml
├── config/
├── tv/
├── movies/
└── transcode/
Ensure that each subdirectory (config, tv, movies, transcode) exists and has the correct permissions before starting the container.
By following this setup, you'll have a robust Plex Media Server running via Docker using the LinuxServer.io image, benefiting from their well-maintained and community-supported Docker containers.
Not yet included in a published release.
/path/to/config:/config: Stores Plex configuration files. Important: Replace /path/to/config with the desired path on your host./path/to/tvseries:/tv: Directory for TV series media./path/to/movies:/movies: Directory for movies media./path/to/transcode:/transcode: Directory for temporary transcode files. Ensure this location has sufficient space./path/to/...) to match your server's directory structure.Devices:
- /dev/dri:/dev/dri: Passes through the Direct Rendering Infrastructure (DRI) device for hardware-accelerated transcoding using Intel GPUs. Remove or modify this line if not using hardware acceleration or if you have a different GPU setup.