So continuing with my Proxmox / docker journey, I decided it was time to fire up Plex and get some kind of media server up and running. Whilst searching through various Plex articles I found that whilst there was plenty of documentation about how to get it up and running, there were very few methods using compose. I am a fan of docker compose and using stacks on Portainer. Personally, I find them easier to manage.
In this article I’ll take you through a quick docker compose set up of Plex, including getting the appropriate token and how to configure it using Portainer, sitting on Proxmox. (I know there are LXC’s out there already, but I’m a fan of docker, and prefer to work with it. I can use both in Proxmox, so see no issue here before you flame me in the comments :)).
For those interested, I’m currently running all of this on my beelink GK mini, which continues to perform like a champion. This server will be direct access play only, so I don’t have any concerns about needing to transcode.
Compose
The image I’ll be using is plexinc/pms-docker. Below is the compose file I’m using.
version: ‘3.7’
services:plex:
image: plexinc/pms-docker
restart: unless-stopped
container_name: plexms
ports:
– “32400:32400/tcp”
– “3005:3005/tcp”
– “8324:8324/tcp”
– “32469:32469/tcp”
– “1900:1900/udp”
– “32410:32410/udp”
– “32412:32412/udp”
– “32413:32413/udp”
– “32414:32414/udp”environment:
– PUID=${PUID}
– PGID=${PGID}
– TZ=Europe/London
– PLEX_CLAIM=claim-<your-string>
– HOSTNAME=”PlexServer”volumes:
– ${USERDIR}/docker/plexms/config:/config
– ${USERDIR}/docker/plexms/transcodes:/transcode
– ${USERDIR}/docker/plexms/media:/media
If you’re familiar with Portainer, most of this would seem pretty self explanatory. The only things that might seem different to other compose files is the number of ports that you need to define for Plex to work properly, as well as the “PLEX_CLAIM” entry.
You may notice I am using $(PUID),$(PGID) and $(USERDIR). This is because I have defined those variables in an environmental file (nano /etc/environment). You could easily substitue that with your own PGID and PUID as per the following lines (for example):
environment:
– PUID=1000
– PGID=1000volumes:
– home/docker/plexms/config:/config
You can get your relevant ID’s from running the command id and your username on the command line. For example:
id root
Obviously, no one would ever use root as the user right? 😉
Plex Claim
You need to use the Plex Claim in order to add this server to your plex account. The procedure for getting the actual token you need is as follows
Visit https://www.plex.tv/claim/
If you’ve already logged into Plex on that machine, the Claim Code should just pop right up:
Copy the code in its entirety including the claim- bit at the beginning. You should then just paste the whole variable into the compose file above (inc claim). For example if your Claim Code was claim-t33iotdCjhnBTwD_14PU then input the whole string as follows:
environment:
– PUID=${PUID}
– PGID=${PGID}
– TZ=Europe/London
– PLEX_CLAIM=claim-t33iotdCjhnBTwD_14PU
– HOSTNAME=”PlexServer”
This will essentially add this new Plex server to your Plex account. Note this claim code changes every 4 minutes, so if you’re slow out of the gate then you need to get a new code by following the instructions again and changing it in your compose file.
Creating Your Library
I also went ahead and created several folders under home/docker/plexms/media (“movies”, “music” and “tvshows”). These become the basis for my media libraries and I will need to populate these. I will probably add an external drive to Proxmox and use that as my file store, but that’s for another tutorial.
Now this tutorial isn’t about how to set up Plex, it was just how to get it up and running using Docker-Compose. This particular server will not be used for remote viewing due to bandwidth constraints. If you do wish to remotely view your library or share it with others, have a look below for some additional steps needed to give the server access to the wider web.
https://github.com/plexinc/pms-docker
Especially pay attention to the ADVERTISE_IP variable section.
With that said, I will want the ability to administer the server remotely. There are several ways to achieve this. For me though, the quickest and by easiest is to use Tailscale. If you’re new to Tailscale, you can read more about it here. I already have Tailscale running on my proxmox server from our initial set up, so you can follow the steps here. I’ve essentially joined the networks together. So if my home network is 192.168.1.0/24 and I am sitting on wifi in a coffee shop on LAN 10.10.10.0/24, i can essentially just type 192.168.1.X:32400 and I have remote access to my Plex machine. As long as I have the tailscale daemon running, we’re good. No port forwards necessary and auth is taken care of by Github.
Further Reading
If any of you are using pfSense, then I have an article here which details how I managed to take care of some firewall issues I was having with Plex. You can read more about that here.
If any of you fancy using Plex to help automate your home cinema lighting or triggering projector screens etc, then the webhook function within plex pairs nicely with Node-red. I also published a walk through here.
Happy Plexing!
If you have any tips or tricks pop them in the comments below or come over to our facebook group to discuss further.
https://www.facebook.com/groups/386238285944105
If you’re considering a renovation and looking at the structured wiring side of things, or maybe you just want to support the blog, have a look below at my smarthome book, it’s available in all the usual places (including paperback)!