Plex
Create Plex Container
Now that we have a place to put our media, we can finally create our Plex container. Navigate to Portainer's web interface.
I will be using docker compose to create the containers. For whatever reason, Portainer calls docker compose files "stacks". Navigate to the server and click on Stacks in the left. Then click on "+ Add stack".
Give the stack a name, like "plex".
I am going to be using the image provided by linuxserver.io as they are stable and work well. The documentation can be found here.
Here is my docker compose file:
---
services:
plex:
image: lscr.io/linuxserver/plex:latest
container_name: plex
network_mode: host
environment:
- PUID=1000
- PGID=1000
- TZ=America/New_York
- VERSION=docker
# - PLEX_CLAIM=optional
volumes:
- /mnt/media:/media
- /var/lib/plexmediaserver:/config
restart: unless-stopped
First, note the UID and GID. If you are using the user created when installing Ubuntu, these will always be 1000. If you have created another user to run Plex, you can look up the PUID and PGID of the user by:
Make sure to subtitute the username you are looking for.
Be sure to set the timezone for the timezone you are currently in. You can look up the correct timezone here.
The PLEX_CLAIM option is used if you are porting over an existing Plex server. For example, you are running it natively on Linux but wish to convert to using docker.
Note what is listed under volumes. If this is your first time using Docker Compose, this is mapping storage. The path to the left of the colon indicates where the storage is located on the host Linux system. The path on the right indicates where this will be mapped to inside of the container. This will also hold true for any other values that contain a colon:
host:container
Here I have mapped the folder with the NFS storage mounted to it (/mnt/media) to a /media folder inside of the Plex container.
I have also mapped the /config folder inside of the container to a folder in the /var/lib folder on the host. I prefer to mount the config files to a location in the /var/lib folder as this is where applications directly installed on Ubuntu normally store their configuration data. I had originally had Plex installed on Ubuntu, but converted over to docker by very simply pointing the container at the existing folder for Plex data. This has carried forward and you will see me mounting the config data folders for containers to the /var/lib folder. You can mount this folder wherever you like as Docker runs as root and will create the folders and set permissions accordingly.
Finally, network_mode: host gives the container direct access to the operating systems network interface.
So now that the compose file is properly set up, paste it into the Web editor box, scroll to the bottom of the page and click "Deploy the stack".
Now you should be able to navigate to the web interface in a browser at
You can then begin the setup process to setup the Plex server. When setting up your media libraries, you can simply select the appropriate type and then find the folder with the browser. For example, add a Movie Library and use the folder /media/movies.
If you want your Plex server to be able to stream outside of you local home network, you will need to set up a port forwarding rule in your router. This will need to direct port 32400 to the ipaddress of the Plex server.
Plex can still stream outside of the local network without this, however it will need to use a Plex relay server which has bandwidth limitations.
Change Plex Settings for Privacy Issues
Plex has been rightly criticized for a few moves where privacy concerns have become an issue. In particular, Plex by default opts into a feature called "Discover Together". This will basically send out emails to users of the Plex server broadcasting what users are watching to all other users. Secondly, Plex will collect playback data.
There is a reddit post located here that outlines how to disable these features. I will outline them here in case they ever disappear.
How to Disable Discover Together Sharing
-
Log into app.plex.tv using your web browser.
-
Select your profile photo in the top-right corner of the screen, then select "View Profile":
-
Select "Edit Profile".
-
Select "Manage who can see your activity".
- Make sure all options are set to private. (Account Visibility defaults to "Anyone," with "Friends Only" currently being the most restrictive choice as of writing.)
How to Disable Sending Playback Data to Plex
-
Log into Plex.tv through a web browser.
-
Navigate to the privacy preferences page located here.
-
Under "Optional Playback Data," you will find "Send playback data to Plex":
- Uncheck "Send playback data to Plex".