0

I'm trying to create a plex container in the "host" mode, the container is created without problems but is not able to obtain network connectivity. I'm running Ubuntu 22.0. I already flushed iptables, allowed port 32400 via ufw but docker ps shows no port information, and docker inspect shows "connection refused" errors.

~$docker ps 
CONTAINER ID   IMAGE                COMMAND   CREATED       STATUS                   PORTS     NAMES
9b30e966f0df   plexinc/pms-docker   "/init"   6 hours ago   Up 6 hours (unhealthy)             plex

~$docker inspect plex

        "Health": {
            "Status": "starting",
            "FailingStreak": 2,
            "Log": [
                {
                    "Start": "2023-08-21T11:33:29.030426144-04:00",
                    "End": "2023-08-21T11:33:29.160688826-04:00",
                    "ExitCode": 1,
                    "Output": "curl: (7) Failed to connect to localhost port 32400: Connection refused\n"
                }
            ]
        }

YML File:

version: "2.20"
services:
  plex:
    container_name: plex
    image: plexinc/pms-docker
    restart: unless-stopped
    network_mode: host

    environment:
      - TZ= ”America/New_York”
      - HOSTNAME=  "plexmediaserver"
      - PLEX_CLAIM= ”claim-ZpdRxxxxxxxxjnAR”
      - ADVERTISE_IP="http://192.168.1.25:32400/"
    volumes:
      - /mnt/vmstation/Plex/PlexData/PMS:/config
      - /mnt/vmstation/Plex/Transcode:/transcode
      - /mnt/vmstation/Plex/Media:/data
Rocky
  • 45
  • 1
  • 6
  • I don't know much about plex, but it looks like the server is not listening on `localhost`, as expected by the healthcheck. The `ADVERTISE_IP` you provide in your `docker-compose.yml` makes me think it may try to bind on that IP instead of `localhost`. Thus, that could explain why the [healthcheck](https://github.com/plexinc/pms-docker/blob/helm-chart-0.1.5/root/healthcheck.sh) is failing. Can you remove the `ADVERTISE_IP` and try again? – norbjd Aug 21 '23 at 16:15
  • @norbjd I added ADVERTISE_IP only after it didn't work. I tried a lot of different combinations already before posting the question to see what I could be doing wrong. – Rocky Aug 21 '23 at 16:45
  • I'd recommend using the approach described in "Bridge Networking" in the [Docker Hub image page](https://hub.docker.com/r/plexinc/pms-docker). All of the `docker run -p` options convert to Compose `ports:` settings. Host networking generally disables Docker's networking layer entirely, and most applications won't need it. It also doesn't work on any setup other than Docker Engine running directly on a native-Linux host. – David Maze Aug 21 '23 at 17:12

1 Answers1

0

It's because of the network_mode directive in your compose file. When you put as host, it will take the ip of your localhost. You have to set the network_mode to bridge network.

version: "2.20"
services:
  plex:
    container_name: plex
    image: plexinc/pms-docker
    restart: unless-stopped
    network_mode: bridge

    environment:
      - TZ= ”America/New_York”
      - HOSTNAME=  "plexmediaserver"
      - PLEX_CLAIM= ”claim-ZpdRxxxxxxxxjnAR”
      - ADVERTISE_IP="http://192.168.1.25:32400/"
    volumes:
      - /mnt/vmstation/Plex/PlexData/PMS:/config
      - /mnt/vmstation/Plex/Transcode:/transcode
      - /mnt/vmstation/Plex/Media:/data
Saleh
  • 70
  • 7
  • Still can't connect with network_mode set to bridge, even with the ports defined and listed. "Output": "curl: (7) Failed to connect to localhost port 32400: Connection refused\n" – Rocky Aug 23 '23 at 05:22