1. Preparation#
- The server needs to have Docker.
- Able to run Docker Compose.
- Plex account.
2. Installation Tutorial#
2.1 Create relevant directories#
mkdir -p 'custom data directory'/plex/config # Plex configuration file directory
mkdir -p 'custom data directory'/plex/transcode # Plex transcoding file directory
mkdir -p 'custom data directory'/plex/data # Plex data file directory
For example:
mkdir -p /usr/plex/config
2.2 Get Plex token#
You can obtain a claim token by visiting https://www.plex.tv/claim to log your server into your Plex account. Copy and paste the token characters into the corresponding position in the docker-compose file below. Necessary operation.
2.3 Create docker-compose file and run#
vim /usr/plex/docker-compose.yml
---
version: '3'
services:
plex:
image: plexinc/pms-docker:latest # Install the latest version
hostname: PlexServer # Custom host name
restart: always # Set restart policy
volumes:
- "'custom data directory'/plex/config:/config" # Plex configuration file directory
- "'custom data directory'/plex/transcode:/transcode" # Plex transcoding file directory
- "'custom data directory'/plex/data:/data" # Plex data file directory
- "'video file save directory':/video"
ports:
- 32400:32400/tcp # Plex web access port, for example, if you want to change it to access through port 8080, modify it to 8080:32400
- 3005:3005/tcp # Plex Companion
- 8324:8324/tcp # controlling Plex for Roku via Plex Companion
- 32469:32469/tcp # access to the Plex DLNA Server
- 32468:1900/udp # access to the Plex DLNA Server
- 32410:32410/udp # current GDM network discovery
- 32412:32412/udp # current GDM network discovery
- 32413:32413/udp # current GDM network discovery
- 32414:32414/udp # current GDM network discovery
# devices: # Share hardware devices with FFmpeg (optional)
# - "/dev/dri:/dev/dri" # Intel QSV
# - "/dev/nvidia0:/dev/nvidia0" # Nvidia CUDA
# - "/dev/nvidiactl:/dev/nvidiactl"
# - "/dev/nvidia-modeset:/dev/nvidia-modeset"
# - "/dev/nvidia-nvswitchctl:/dev/nvidia-nvswitchctl"
# - "/dev/nvidia-uvm:/dev/nvidia-uvm"
# - "/dev/nvidia-uvm-tools:/dev/nvidia-uvm-tools"
# - "/dev/video11:/dev/video11" # Raspberry V4L2
environment:
TZ: Asia/Shanghai # Container internal time zone
PLEX_UID: 0 # User ID created inside the container (do not change if you don't understand)
PLEX_GID: 0 # User group ID created inside the container (do not change if you don't understand)
PLEX_CLAIM: claimToken # Claim token for the real server, you can obtain a claim token by visiting https://www.plex.tv/claim to log your server into your Plex account
ADVERTISE_IP: hostIPAddress:32400/ # Fill in the fixed IP or domain name for external access, if not available, you can delete this line
2.4 Open corresponding ports, etc.#
Whether it is the local firewall or the firewall in cloud platforms such as Alibaba Cloud, the corresponding ports must be opened. Among them, 32400 must be opened, and my colleague also opened 3005. Other ports are not opened because it is a VPS and does not require DLNA and GDM.
2.5 Check the access result#
Check the result by accessing the Plex management page through the domain name
http://'domain':32400
3. Related issues#
3.1 Remote access is "indirect/relay"#
Because Docker is used for installation, the IP displayed by the network card allocated inside the container is an internal IP, so in the management interface's "corresponding server"-"remote access" section, the internal IP is an internal network starting with 172, and the public external IP port may be 0.
Click on "Manually specify port" below, fill in the default: 32400, click apply, and after running, the problem will be solved. It will display "Full access outside your network".