Docker Plex requires setup for every restart

I’m pretty new to Docker, so I might not understand everything fully.

The problem I have is, that whenever I restart the server or the docker image, my Plex server ends up having to re-run the setup process.

The weird part is, that the setup only shows up when I connected from the local network to plex.tv. If I connect to external-IP:32000 in my local network the server shows up as running fine, but the remote connection can’t be established.

So whenever I restart my server or reload the Docker image, I have to connect to my local network and open plex.tv, then give my server a name, allow remote connection, select the media directories and only then can one connect to plex from a remote site.

Is there a way to make the setup permanent, so I don’t have to do this anymore?

Here’s the excerpt from my docker-compose.yml:

    plex:
        container_name: plex
        image: plexinc/pms-docker
        restart: always
        ports:
            - 32400:32400/tcp
            - 3005:3005/tcp
            - 8324:8324/tcp
            - 32469:32469/tcp
            - 1900:1900/udp
            - 32410:32410/udp
            - 32412:32412/udp
            - 32413:32413/udp
            - 32414:32414/udp
        environment:
            - TZ=Europe/Zurich
            - PLEX_CLAIM=claim-<TOKEN>
            - ADVERTISE_IP=http://192.168.1.10:32400/
        hostname: plex.server.local
        network_mode: host
        volumes:
            - /data/config/plex:/config
            - /media/Movies:/movies

I’ve seen this mentioned in other places as well, but as with the other thread, when I try to access https://plex.tv/pms/resources.xml, I get an XML saying that I need to sign-in. What token do I have to provide and how to get this to show up for me?

Hope we can find some solution here, as running Plex in Docker is really nice. :smile:

Besides adding your PLEX_CLAM token, you also need to claim your server in the general settings!

But it is claimed to my account!

I also just noticed, if I don’t access the Plex server for a few hours, it suddenly stops being available from remote until I directly access it local with IP:32400/web. The interface then still shows it’s not accessible from the outside, but after a refresh it starts working again.

Hmm, seems inconclusive to me.

Are your using WOL or energy saving options on your nic?
Just asking, because i never experienced that PMS becomes unavailable anytime other then when i restart my internet router, docker host or my docker container.

Are you aware that you use the :latest implicitly which is the public build?
You might want to add :plexpass to your image to use the Plex Pass build.

To rule out permission problems, you might want to add permission mapping to the environment section of your compose file:
PLEX_UID The user id of the plex user created inside the container.
PLEX_GID The group id of the plex group created inside the container.

Make sure that id {docker host user} matches the uid:gid of /data/config/plex and they are the same for PLEX_UID and PLEX_GID.

Thanks for the reply! :smile:

I have switched to the plexpass image and set the user id and group id.

The connection behavior nearly seems random. Like I’m currently remote when I recreated the Docker image with the new settings. When I went to plex.tv it presented me with the setup screen, after I went through that, I could load up the server settings, but it failed to make a connection. Then the server was suddenly not available anymore from plex.tv. I switched to remote-ip:32400 and couldn’t see the server either.

Now, I’ve set up a port forwarding ssh connection to access the plex server from “localhost”. Since I’ve never accessed plex from the server itself (headless setup), I first had to sign in. After doing so, the server was immediately available on plex.tv and I didn’t even have to specify the remote port 32400 as I usually had to.

I’ll also check for power-saving nic, however since SSH never fails, I kind of doubt that this is an issue and when I access remote-ip:32400 I always get the plex interface loaded.

For now I hope that this sign-in directly on the server fixed the weird behavior and it will now work fine.

However this still leaves me with the initial issue, that you need to run the setup whenever you recreate/update the docker instance. Maybe I’m using Docker wrong, but is there a way, that I never have to see this screen again?

Nope, that didn’t fix the issue. It’s like Plex is forgetting that it had already established the connection and then you have to simply press “reconnect” again and woosh it works. Just keep connected please! :neutral:

Solution

Don’t run multiple Docker containers of Plex on your machine!

Turns out while playing around with Docker for the first time and trying to get Plex to work in the Docker network, I created two additional containers. This then must have caused some issues with announcing which is the real Plex instance.

The root cause was for the longest time not discovered because I’m a Docker noob I couldn’t access the famous resources.xml file. With the help of kopfpilot I finally managed to access it and I got to see the wrongfully advertised networks.

Accessing the resources.xml file

According to kopfpilot accessing https://plex.tv/pms/resources.xml directly works in Firefox after you’ve logged in at https://www.plex.tv/
But I’m using Chrome and not Firefox and there it doesn’t seem to work. My theory might be because of some domain name/session issue, since the “API” uses plex.tv while the site only works with www.plex.tv.

With the following URL one can access the file also with Chrome, but in order to do that you’ll first have to get your Plex token:
https://plex.tv/pms/resources.xml?includeHttps=1&includeRelay=1&X-Plex-Token=xxxxxxxxxxxxxxxxx

You can get the Plex token like this: https://support.plex.tv/hc/en-us/articles/204059436-Finding-an-authentication-token-X-Plex-Token
And if that way doesn’t work, you could activate token logging in the PMS settings and find a valid token in the PMS logs.

The resources.xml file provides a list of all the endpoints that have been announced to plex.tv. If you see IP addresses that you don’t know and that aren’t relay addresses, then you might have a configuration issue or multiple instances running.

Hope this helps someone!

I am glad things are sorted of for you now :slight_smile:

An update on how to access the resources.xml:
My assumption that resources.xml could be accessed in Firefox without adding the X-Plex-Token to the URL was wrong. It was actualy working for me for a long time, but stopped doing so after i used chrome with added X-Plex-Token. Now I can not recreate what ever caused it to not require the X-Plex-Token. I must have had a cookie of some sorts that survived for a long time.

For those of you having this issue, make sure PLEX_CLAIM is added to the container’s environment variables. I hadn’t specified it and everything was working for me after the initial startup and setup (able to log in, claimed with user account, etc.), but then following a system reboot, it went back to the setup wizard even though the /config volume was still mounted and had valid config files in it. Removing the docker container, re-creating it but adding PLEX_CLAIM (with a currently valid token, so get a new one) and starting it again, and it came right back up.