Run Plex as a Docker Container on a Raspberry Pi using Docker Compose
3 minute read
Goal
Setup a Plex server as a Docker container hosted on a Raspberry Pi.
Mount the media share
Create a target mount point
On the Raspberry Pi, create a directory that will act as the mount point for the remote file share. In this example, we’ll create a directory called /media-share
in the root of the file system:
$ sudo mkdir /media-share
Setup credentials to be used to access the NAS media share
Add the NAS media share username and password to a file named cifs-credentials
so it can be used when you mount the drive as it’s more secure to store your SMB/CIFS username and password in a credentials file instead of directly in the /etc/fstab
file.
$ sudo nano /etc/cifs-credentials
In the editor, enter your username and password like this:
username=<username>
password=<password>
Next, change the permissions of the credentials file to ensure that only root can read and write it:
$ sudo chmod 600 /etc/cifs-credentials
Test the share is mounted
Now you can mount the share using the target mount point and the credentials file. Once mounted browse to the mount and check you can see the contents.
$ sudo mount -t cifs -o credentials=/etc/cifs-credentials //path/share /media-share
$ cd /media-share
$ ls -lh
Configure the share to mount automatically
To ensure that the remote share is automatically mounted at startup, add an entry to your /etc/fstab
file and add the following line at the end of the file:
$ sudo nano /etc/fstab
//path/share /media-share cifs credentials=/etc/cifs-credentials,nofail 0 0
Run Plex as a Docker container
Create the docker-compose file
Create a new directory to save the Docker Compose file for the Plex container.
$ mkdir /docker/plex
Change directory into the new directory and create a Docker Compose file.
$ cd /docker/plex
$ nano docker-compose.yml
Paste the Plex Docker Compose configuration into the file. This Docker Compose file references the Docker container detailed in the referenced Docker Hub link below.
# Plex Server
# https://hub.docker.com/r/linuxserver/plex
#
# Notes:
# - Web server is found at http://<your-ip>:32400/web
# - Media files are stored on a NAS
# - A path to the NAS is mounted as /media-share
version: "3"
services:
plex:
image: lscr.io/linuxserver/plex:latest
container_name: plex
network_mode: host
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Copenhagen
- VERSION=docker
- PLEX_CLAIM= #optional
volumes:
- /opt/plex:/config
- /media-share/tv:/tv
- /media-share/movies:/movies
restart: unless-stopped
Start the Docker container
Run the Docker Compose command to start the container and include the -d
so it runs it as detached from the CLI.
$ sudo docker-compose up -d
Connect to the Plex web interface
Connect to the plex server
http://<ip-docker-host>:32400/web
As part of the Plex setup you can browse to the media files using the media
folder that is mapped to the media-share
mount point.
References
Feedback
Was this page helpful?
Glad to hear it!
Sorry to hear that.