Plex Media Server is a software application that turns any machine in your network into a personal media streaming service: your own Netflix or Spotify. You organize your collection of movies, TV shows, music and photos in one place and stream it to any device: smart TVs, phones, tablets or PCs.
In this guide we will install Plex on a home server running Ubuntu Server, using Docker. Once it is up you will be able to stream your library from your local network, and from anywhere in the world if your router allows it.
If you do not have a home server yet, start with Build your own home-server. You will also need a free Plex account and, optionally, an external USB hard drive to store your media.
Optional: connect an USB hard drive
Create a folder to mount the disk: sudo mkdir -p /mnt/hdd
Find the device of your drive (for example /dev/sdb1):
lsblk
Get the UUID of the partition:
blkid /dev/sdb1
Edit fstab: sudo nano /etc/fstab and add a line with the UUID you just obtained:
UUID={{OBTAINEDUUID}} /mnt/hdd ext4 auto,nofail,noatime,rw,x-systemd.device-timeout=10s 0 0
The options: nofail lets the server boot even if the disk is not connected, noatime reduces writes to the disk, and x-systemd.device-timeout limits how long the system waits for the device. A good reference is Mounting an external drive on Ubuntu Server.
Apply the changes and verify the mount:
sudo mount -a
df -h /mnt/hdd
Create a Plex account
If you do not have one, create a free Plex account and stay logged in, because we will claim the server with it in a minute.
Install Docker
First of all install Docker CE into your server. Remember to run the post-install steps so you can use docker without sudo.
Install Plex with Docker
Get a Plex claim token while logged in with your account. You will use it to link the new server to your Plex account.
Create the directories the container will use:
sudo mkdir -p /var/lib/plexmediaserver/transcode /var/lib/plexmediaserver/media
Replace the placeholders and run the following in your server. Use your own timezone, your UID (id -u, usually 1000), the claim token, and the paths where your media is mounted:
docker run \
-d \
--name plex \
--network=host \
-e TZ="Europe/Madrid" \
-e PLEX_CLAIM="{{PLEXTOKEN}}" \
-e PLEX_UID=1000 \
-e PLEX_GID=1000 \
-v /var/lib/plexmediaserver:/config \
-v /var/lib/plexmediaserver/transcode:/transcode \
-v /var/lib/plexmediaserver/media:/data \
-v /mnt/hdd/movies:/movies \
-v /mnt/hdd/music:/music \
--restart=always \
--pull=always \
plexinc/pms-docker:1.32.8.7639-fb6452ebf
–network=host makes the container use the server network directly, so Plex listens on the usual port 32400. –restart=always keeps the server running after reboots, and the pinned image tag keeps your version stable. To update Plex later, get a new tag from Docker Hub, remove the container and run the command again with the new tag.
Access to Plex
Wait until the container is fully up (you can check it with docker ps) and open http://{{YOURSERVERIP}}:32400 in your browser. The web app will ask you to sign in, and that is it: your server is claimed and ready to use.
From any other device (TV, phone, tablet) install the Plex app, log in with the same account, and your home server will appear automatically.
Organize your media
Put your content in the mounted folders, for example /mnt/hdd/movies and /mnt/hdd/tv, and scan it from the Plex web app. Plex will download metadata, posters and episodes for you, so keep a clean naming convention:
/mnt/hdd/movies/Inception (2010)/Inception (2010).mkv
/mnt/hdd/tv/Show Name/Season 01/Show Name S01E01.mkv
If Plex does not pick up a title, check the logs: docker logs plex. And if you cannot reach the web app, make sure port 32400 is not filtered by your firewall: sudo ufw status.


Pingback: Build your own home-server - Kustomiz-it