Media Server (Docker) - uthomelabs/guides GitHub Wiki
This guide will help you get Plex media server running in a docker container. We will look at two ways of doing this:
- running a container directly
- using a Docker tool called
compose
to manage the setup in a more reproducible way
We won't be going into the pros and cons of running in Docker vs. other configurations such as bare metal or in a VM and we won't get into much depth on a lot of the specifics of what you can do with Docker (there is a lot to it). For the purposes of this demo we will be using the official image published by Plex (source code) though other images do exists that may have differences in features they might provide.
Running with Docker directly
A common way people getting started with Docker will learn how to run containers is by just running them using the docker run
command. Let's take a look at how we would do this with Plex.
Basic considerations
It may be useful to refer to the documentation provided for the image in getting things up and running but there are a few things we need to consider before we can just run our container and have it do something useful:
- The network mode we want to use: for the sake of simplicity we will stick with
host
mode for now though other useful and interesting network configurations withbridge
andmacvlan
types are quite doable - We need a place to store the Plex database/configuration at minimum: for this demo we will use a Docker volume though you may also be interested in using a mount from a known path on your filesystem
- Your Plex server won't be very useful without some media so we will want to mount a path that contains some media: in this case we have some pre-selected content available for this lab
Getting our basic container running
To bring up the first version of our docker container for this lab just run the following two commands:
# Create a basic local volume to store the Plex database and configuration
docker volume create plex-config
# Run a container from the official plex image
docker run \
-d \
--name plex \
--network=host \
-e TZ="America/Denver" \
-v plex-config:/config \
-v /mnt/media:/data \
plexinc/pms-docker
Cleaning up
If you want to clean up after yourself you can just do:
docker rm -f plex
docker volume rm plex-config
Using compose (preferred)
When we have services that we may want to be able to quickly recreate and easily tweak settings for using Docker one really nice tool is to use docker compose. It allows us to define our entire desired service configuration in a file and bring it up and down at will. It gives us the freedom to not worry about whether the container might be deleted and to freely recreate it if there are problems. To translate the same thing we did above into a docker compose file just create a file named docker-compose.yml
with the following contents:
volumes:
plex-config:
services:
plex:
image: "plexinc/pms-docker"
container_name: "plex"
environment:
TZ: "America/Denver"
network_mode: "host"
volumes:
- "plex-config:/config"
- "/mnt/media:/data"
restart: "unless-stopped"