Remote-access Guide

docker plex remote access

by Estell Cole Published 2 years ago Updated 1 year ago
image

What port is Docker Bridge on?

directly hitting the server with Docker Bridge networking on port 32400

Why do clients think the server is Remote?

When I started writing this up, there was a much more hacky solution involving custom DNS entries for <my id>.plex.direct records which solved this part. However it appears the solution was much more simple.

Where is the database stored in Docker?

Inside the docker container, the database is stored with a Library/Application Support/Plex Media Server in the config directory.

How does a bridge work in Docker?

This network is connected to the physical network via an internal router and docker configures this router to forward certain ports through to the containers within . The host networking uses the IP address of the host running docker such that a container's networking appears to be the host rather than separate. The macvlan networking creates a new virtual computer on the network which is the container. For purposes of setting up a plex container, the host and macvlan are very similar in configuration.

What does hostname do in Docker?

HOSTNAME Sets the hostname inside the docker container. For example -h PlexServer will set the servername to PlexServer. Not needed in Host Networking.

How to update plex media server?

These two images do not have any Plex Media Server binary installed. Instead, when these containers are run, they will perform an update check and fetch the latest version, install it, and then continue execution. They also run the update check whenever the container is restarted. To update the version in the container, simply stop the container and start container again when you have a network connection. The startup script will automatically fetch the appropriate version and install it before starting the Plex Media Server.

What is plex_claim?

PLEX_CLAIM The claim token for the server to obtain a real server token. If not provided, server is will not be automatically logged in. If server is already logged in, this parameter is ignored. You can obtain a claim token to login your server to your plex account by visiting https://www.plex.tv/claim

Does Plex Media Server have permissions?

Permissions of mounted media outside the container do apply to the Plex Media Server running within the container. As stated above, the Plex Media Server runs as a specially created plex user within the container. This user may not exist outside the container and so the PLEX_UID and PLEX_GID parameters are used to set the user id and group id of this user within the container. If you wish for the Plex Media Server to run under the same permissions as your own user, execute the following to find out these ids:

Can you forward plex to a different port?

By default you can forward port 32400, but if you choose to use a different external port, be sure you configure this in Plex Media Server's Remote Access settings. With this type of docker networking, the Plex Media Server is essentially behind two routers and it cannot automatically setup port forwarding on its own.

Compose

The image I’ll be using is plexinc/pms-docker. Below is the compose file I’m using.

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

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.

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.

How does Docker work on Windows?

Docker on Windows works differently than it does on Linux; it uses a VM to run a stripped-down Linux and then runs docker within that. The volume mounts are exposed to the docker in this VM via SMB mounts. While this is fine for media, it is unacceptable for the /config directory because SMB does not support file locking. This will eventually corrupt your database which can lead to slow behavior and crashes. If you must run in docker on Windows, you should put the /config directory mount inside the VM and not on the Windows host. It's worth noting that this warning also extends to other containers which use SQLite databases.

Where is the database stored in Docker?

Inside the docker container, the database is stored with a Library/Application Support/Plex Media Server in the config directory.

What does hostname do in Docker?

HOSTNAME Sets the hostname inside the docker container. For example -h PlexServer will set the servername to PlexServer. Not needed in Host Networking.

How does a bridge work in Docker?

This network is connected to the physical network via an internal router and docker configures this router to forward certain ports through to the containers within . The host networking uses the IP address of the host running docker such that a container's networking appears to be the host rather than separate. The macvlan networking creates a new virtual computer on the network which is the container. For purposes of setting up a plex container, the host and macvlan are very similar in configuration.

Can you add /run to volumes in Docker?

As a workaround you can add - /run to volumes in your docker-compose.yml or -v /run to the docker create command.

Can you use Docker Compose on ARM?

Using docker-compose on ARM devices. The provided docker-compose templates use the plexinc/pms-docker image which is the amd64 build and won't work on ARM devices. To use docker-compose with ARM devices, you must first build one of the ARM images locally.

Can you forward plex to a different port?

By default you can forward port 32400, but if you choose to use a different external port, be sure you configure this in Plex Media Server's Remote Access settings. With this type of docker networking, the Plex Media Server is essentially behind two routers and it cannot automatically setup port forwarding on its own.

image

Installing Docker

  • This command will fetch the docker installation script and execute it. curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh For security purposes, if you want to have a dedicated user for the Plex container, we can run some commands so the user can run docker without sudo privileges. sudo groupadd dockersudo gpasswd -a $USER docker To verify that the installation …
See more on github.com

Creating The macvlan Network

  • Simply put, a container connected to a Macvlan Network has its own MAC address, making it appear like it is a physical device directly connected to the network. It is like an equivalent of the bridge-networking in virtual machine applications. docker network create -d macvlan --subnet=192.168.0.0/24 --gateway=192.168.0.1 --ip-range 192.168.0.240/28 -o parent=eth0 pub_…
See more on github.com

Creating The Plex Container

  • Before we create the container, we have to create the folders that are required for plex: *config, media and transcode". (transcode is optional). We go to the user's home and run the following commands: cd ~ mkdir plex cd plex mkdir media Note that if you are hosting your media like me on a removable drive, you can skip the above command Next, we create and run the plex contain…
See more on github.com

Next Steps

  • After the initial configuration, you have to enable port forwarding in your router to map the local port to the public port. For simplicity purposes we can set it to 32400:32400. Next, we go the Plex web interface/app -> Settings -> Remote Access (Left-hand side) -> Input the ports. I recommend manually opening the ports vs. UPNP for better securit...
See more on github.com

Usage

Parameters

Users/Groups

Tags

Config Directory

Useful Information

  1. Start the container: docker start plex
  2. Stop the conrainer: docker stop plex
  3. Shell access to the container while it is running: docker exec -it plex /bin/bash
  4. See the logs given by the startup script in real time: docker logs -f plex
See more on hub.docker.com

Fedora, CentOS, Red Hat

Running on A Headless Server with Container Using Host Networking

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9