Setup Plex with Docker Compose

May 2, 2023 minute read

Header Image

Originally, I installed Plex on an instance as a service and found that updating or moving it to another instance wasn't that easy. I didn't want to spend the time remembering how I configured it or how to update it, so I though, why not run it in Docker?

This setup is based off the plexinc/pms-docker docker image.

Ok, let's just jump into it, no need to explain my life story.

Setup

First, you'll need to create the docker-compose.yml file. We won't need a Dockerfile here because we can configure everything we need with the plexinc/pms-docker image. We really just need to pass in some environment variables and volumes.

docker-compose.yml file

There are a number of different configurations you can use in the docker-compose.yml file. Below are some essential configurations for setting up Plex.

Server IP

My docker host IP is 192.168.1.100, so I set the ADVERTISE_IP environment variable to that, but make sure you update the IP address to whatever your docker host IP is. If you don't want to use host as the network mode and prefer bridge mode, you'll need to make sure you enable port mapping for the required ports. More information can be found here.

Volumes

You'll also need to make sure you update your volumes to be the path of your persistent storage. I have a 4TB external hard drive mounted at /mnt/plex that contains all of my media and configs. This was the same content that I was using when running Plex as a server, it can be mounted within the docker container to be used as media. No need to make changes, but with a new config directory, you'll need to let Plex update metadata information, cache, etc.

Deploy Resources

Depending on how many people use your Plex server and what kind of transcoding you need to do, you may need to adjust your deploy resources. I found that .5 CPU and 1GB of memory for the container works well for now. You can find more information on deploy resources here.

Plex Claim

Make sure you run through the claim process for your server, you can do this by going to https://www.plex.tv/claim/. Then, update the PLEX_CLAIM environment variable with your claim code.


Here is my docker-compose.yml file:

version: "3.8"
services:
  plex:
    image: plexinc/pms-docker
    container_name: plex
    network_mode: host
    environment:
      - ADVERTISE_IP=http://192.168.1.100:32400/
      - PLEX_CLAIM=claim-asdfasdf12341234-
      - TZ="America/Los_Angeles"
    hostname: plex.domain.com
    volumes:
      - /mnt/plex/movies:/movies
      - /mnt/plex/tv:/tv
      - /mnt/plex/config:/config
    restart: unless-stopped
    deploy:
      resources:
        limits:
          cpus: '2'
          memory: 2048M

Running the container

Once you have your docker-compose.yml file setup, it's time to try and start the container. You can do this with:

docker-compose up -d


I prefer using the -d or --detach option, which will allow it to run in the background.

Should look something like

$ docker ps --filter name=plex
CONTAINER ID   IMAGE                COMMAND   CREATED      STATUS                PORTS     NAMES
95901ea2c912   plexinc/pms-docker   "/init"   2 days ago   Up 2 days (healthy)             plex


Once the container is running, you should be able to connect with it at http://192.168.1.100:32400/web. From there, you can configure and make changes as you see fit. These changes will be saved in the /mnt/plex/config:/config volume that was mounted in the docker-compose.yml file.


Troubleshooting

If the container didn't come up smoothly, the first thing to do is check the logs. This can be done with

docker logs plex

You can add --follow to that command to do a tail of the logs. These logs should show you what is going on and give you some pointers on how to solve the problem.

A couple issues you might run into are directory/file permissions within the volumes you've mounted. The other issue you might run into is the volume may have been the wrong path, so checking it again wouldn't hurt.


Conclusion

Hopefully it went smooth for you and you have Plex running in a container. This was a simple configuration, but feel free to get as complex as you need for your setup, this is a good starting point to get Plex up and running. Thank you.

×