If you’re a movie, TV show, or music enthusiast, you’ve probably heard of Plex Media Server. Plex allows you to organize and stream your media collection, making it easy to access from any device, anywhere. But instead of running Plex directly on your computer, you can host it in a containerized environment with Docker. With Docker Compose, you can streamline the setup process, making it easier to run and manage your Plex server.
In this guide, we’ll show you how to host your own Plex Media Server using Docker Compose for a clean and efficient setup.
What is Plex Media Server?
Plex Media Server is a media management platform that enables you to store and stream your personal collection of movies, TV shows, music, photos, and more. Plex automatically organizes your content and provides metadata, such as descriptions, cover art, and ratings, making your library look polished and professional.
Why Use Docker Compose for Plex?
Docker allows you to containerize your Plex Media Server, isolating it from your local machine. Docker Compose simplifies the management of multi-container applications, making it easier to configure, start, stop, and maintain your Plex server.
The benefits of using Docker Compose for Plex include:
• Consistency: The setup will be the same across different machines, so it’s easy to replicate.
• Portability: You can move the server to different environments with minimal hassle.
• Isolation: Running Plex in a container isolates it from the rest of your system, making it easier to manage.
• Scalability: You can scale or update your Plex setup without affecting other services.
Prerequisites:
Before we begin, you need:
1. Docker and Docker Compose installed on your system.
2. A Plex account (free or premium, depending on your needs).
3. Media files stored in a directory on your computer or NAS (Network-Attached Storage).
4. Basic understanding of command-line usage.
Step 1: Install Docker and Docker Compose
If you don’t already have Docker and Docker Compose installed, follow these steps to install them:
• For Docker installation:
• On macOS: Use Docker Desktop for Mac.
• On Linux: Follow the installation guide here.
• For Docker Compose installation:
• Follow the official installation guide here.
Step 2: Create a Docker Compose File for Plex
Once Docker and Docker Compose are installed, the next step is to create a docker-compose.yml file that defines your Plex Media Server container. Follow these steps:
1. Create a new directory for your project:
mkdir plex-media-server
cd plex-media-server
2. Create a new docker-compose.yml file inside this directory:
touch docker-compose.yml
3. Open docker-compose.yml in a text editor (e.g., VS Code, Sublime Text, etc.) and add the following configuration:
version: '3.7' services: plex: image: plexinc/pms-docker container_name: plex environment: - PLEX_CLAIM= # Your Plex claim token (optional for setup) - ADVERTISE_IP=http://your-server-ip:32400 - PLEX_UID=1000 - PLEX_GID=1000 volumes: - ./config:/config - ./media:/data ports: - 32400:32400 restart: unless-stopped
Explanation of key sections:
• image: Specifies the Docker image to use (official Plex image).
• container_name: The name of the container.
• environment: Environment variables for configuring Plex, including your Plex claim token (you can get it from Plex Claim).
• volumes: Mounts directories from your host machine to the container. ./config stores Plex’s configuration, and ./media is where your media files are stored.
• ports: Exposes port 32400 to the host machine so you can access the Plex web interface.
• restart: Ensures the container restarts automatically if it fails or when the machine restarts.
Step 3: Start Plex Media Server
Now that you have your docker-compose.yml file set up, it’s time to start your Plex Media Server.
1. In your terminal, run the following command to pull the necessary Docker image and start the container:
docker-compose up -d
2. Docker Compose will automatically download the required image and start the Plex Media Server container in detached mode.
3. To verify that Plex is running, visit http://localhost:32400/web in your web browser. You should see the Plex setup page.
Step 4: Configure Plex
1. On the Plex setup page, sign in with your Plex account.
2. Follow the on-screen instructions to configure your media library by pointing Plex to the ./media folder (where your movies, TV shows, music, etc., are stored).
3. Plex will automatically scan your media and organize it with metadata, making it easy to browse.
Step 5: Manage Your Plex Media Server
Once your Plex Media Server is running, you can access it from any device in your home network. You can stream content to devices like:
• Smart TVs
• Smartphones (using the Plex app)
• Laptops and desktops
To manage the server, use the Plex web interface or install the Plex app on your preferred device.
Step 6: Optional Configurations
• Update Plex: To update the Plex server, simply run the following command:
docker-compose pull && docker-compose up -d
• Persistent Storage: Make sure to back up your ./config directory to prevent loss of server settings and media data.
• Automatic Restart: The restart: unless-stopped policy ensures the server will restart automatically after a reboot.
Conclusion:
Hosting your own Plex Media Server using Docker Compose gives you full control over your media library and makes it easier to manage and scale. Whether you’re streaming movies and TV shows to your TV, phone, or tablet, Plex ensures that all your media is organized and easily accessible.
With Docker Compose, you can quickly set up and maintain your Plex server, while also keeping everything portable and isolated from your local system. Start using Plex today and enjoy your own personal media streaming server from anywhere!
Leave a Reply