Universal media servers have become increasingly popular, enabling us to stream audio, video, and image files from a single location to various devices. Setting up a universal media server using Docker offers a flexible, isolated, and easily manageable solution. Let's delve into a step-by-step guide on how to achieve this.
Before we commence, ensure you have Docker and Docker Compose installed on your system. This guide assumes you're using a Linux-based OS, such as Ubuntu.
Setting Up the Environment
Begin by creating a new directory for your media server and navigate into it:
> mkdir universal-media-server
> cd universal-media-server
Creating the Docker Network
Establish a dedicated Docker network for your media server to ensure proper communication between containers:
> docker network create media-server-network
Initializing the Docker Compose File
Initialize a new Docker Compose file, which will handle the configuration of your media server:
> echo 'version: "3.8"' > docker-compose.yml
Now, let's add the necessary services to this Docker Compose file.
Configuring Docker Services
We'll use Plex as our media server software and_PORTainer for managing Docker. Both require a specific configuration within our Docker Compose file.
Plex Media Server
Add the following Plex configuration to your Docker Compose file:
> cat >> docker-compose.yml << 'EOF'
services:
plex:
image: plexinc/pms-docker:latest
network_mode: host
volumes:
- ./config:/config
- ./transcode:/transcode
- ./media:/media
environment:
- PUID=1000
- PGID=1000
- TZ=America/New_York
restart: always
EOF
Portainer
Next, add a Portainer configuration to manage your Docker containers:
> cat >> docker-compose.yml << 'EOF'
portainer:
image: portainer/portainer
command: -H localhost -p 9000
network_mode: host
restart: always
EOF
Now, let's set up some convenient environment variables to ease the initial setup process.
Setting Up Environment Variables and Volumes
To manage access rights and simplify configuration, create a `.env` file and add the following variables:
PUID and PGID
Set correct user IDs (PUID) and group IDs (PGID) for smooth functionality:
> echo 'PUID=1000' >> .env
> echo 'PGID=1000' >> .env
Media Directories
Specify the local paths for your media library and the transcode directory:
> echo 'MEDIA_DIR=/path/to/your/media' >> .env
> echo 'TRANSCODE_DIR=/path/to/transcode' >> .env
Remember to replace `/path/to/your/media` and `/path/to/transcode` with your actual directory paths.
Finally, launch your new media server with the updated commands:
Initializing and Running the Media Server
Pull the required Docker images and start the containers:
> docker-compose pull
> docker-compose up -d
Head to
Dockerizing your universal media server provides enhanced flexibility and isolation. Regularly update your containers and monitor your server's performance for an optimal streaming experience.