Skip to content

Plex Server made easy with Docker

Launching a plex server is made easy when run in docker. It’s ideally a 3 step process, but if you have a fresh machine, you should probably install docker first.

Step 0: Install Docker

This is for an Ubuntu 24.04 machine, like the one I’ve been using in my ongoing HTPC series. Full instructions can be found here, but I’ll highlight the important bits.

Uninstall old versions (this should be an issue if you have a fresh system)

for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; \
  do sudo apt-get remove $pkg; done

Setup docker repo

sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings

sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Add user to docker group

If you’re getting a Permission Denied error when you run docker commands, or got tired of using sudo, run the following

sudo usermod -aG docker $USER

Logout and login again and you can now run docker commands without using sudo

Step 1: Make folders for Plex

If you’ve been following my HTPC series, you’ll know that I put all data from all my various applications onto a shared RAID array mounted at /raid. So let’s make a folder for plex there, along with 3 needed subfolders.

mkdir -p /raid/plex/config
mkdir -p /raid/plex/data
mkdir -p /raid/plex/transcode

These folders exist externally to the docker container, so your data will persist when the container is stopped or even destroyed. Very handy for upgrading.

Step 2: Run Plex

This is the single command you need to run to start a plex server in docker.

docker run -d \
    --name plex \
    --network=host \
    -e TZ=America/Chicago \
    -v /raid/plex/config:/config \
    -v /raid/plex/data:/data \
    -v /raid/plex/transcode:/transcode \
    --restart unless-stopped \
    plexinc/pms-docker

Change the America/Chicago timezone to something more geographically appropriate for you. Other than that, copy paste.

If you got a Permission Denied error, scroll up.

Step 3: Configure Plex

This is all done from the GUI. Open a browser and navigate to htpc_hostname:32400/web/index.html

Plex should load and redirect you to plex.tv for authentication. Sign in and commence with the setup.

I made my plex server name the same as my hostname, for consistency if nothing else.

Intermediary step: copy your media into that /raid/plex/data folder. My folder hierarchy looks like…

/raid/plex/data
├── movies/
│   ├── Argo (2012)/
│   ├── Gladiator (2000)/
│   ├── Return of the King (2003)/
│   └── ...
└── tv/
    ├── Firefly/
    ├── Game of Thrones/
    └── ...

My movies and tv shows exist as separate libraries. To add them, click the eponymous button. Select the library type (movies). And then “Browse for Media Folder”

At this point, the UI gets glitchy, so I’d recommend just typing in the path. This path is going to be relative to what the Docker container sees, so in my case, it’ll be at /data/movies. Select Add, and Add Library. Then repeat for the TV folder. Or Music folder. Or photos, or whatever plex-supported libraries you may have.

Click Next when finished adding Libraries and you should see a completion screen. Click Done and your Plex server is ready to go.

Addendum: Updating Plex

After a few months with your new server, the “Update Available” notification begins to annoy you. It offers to download a .deb package, but of course that’s useless here. So how do you upgrade your Plex Server when in Docker? Simple: destroy it and start over.

Ok maybe not that drastic. Essentially you just repeat step 2. First: stop the server and remove the container

docker stop plex
docker rm plex

Pull an updated image

docker pull plexinc/pms-docker

And re-run the command from step 2

docker run -d \
    --name plex \
    --network=host \
    -e TZ=America/Chicago \
    -v /raid/plex/config:/config \
    -v /raid/plex/data:/data \
    -v /raid/plex/data:/transcode \
    --restart unless-stopped \
    plexinc/pms-docker

The contents of your config, data, and transcode folders will help the new container seamlessly pick up where the old one left off.