Set a static ip for Plex Media Server running in a Docker container with macvlan networking

Server Version#: 1.26.2.5797
Player Version#: 4.81.1

Hello Everyone,

I’m hoping to get some help with a networking issue running Plex Media Server in a Docker container on top of Ubuntu Server 20.04 LTS. I’m using the latest version of Portainer to manage my containers with Stacks (docker-compose). The problem I’m having is assigning a static IP address for the container. I created a macvlan network in Portainers Networks with a range outside of my psfsense routers DHCP range. I’ve put my current working configuration below.

services:
  plex:
    image: plexinc/pms-docker:plexpass
    container_name: plex_docker
    network_mode: my_macvlan
    mac_address: 02:42:c0:a8:01:c8
    environment:
      - NVIDIA_VISIBLE_DEVICES=all
      - PUID=1000
      - PGID=1000
      - VERSION=docker
      - TZ=America/Chicago
      - UMASK_SET=022 #optional
    volumes:
      - /home/containers/plex:/config
      - /media/Video/TV:/tv
      - /media/Video/Movies:/movies
      - /media/Video/3D:/3D
      - /media/Music:/music

    restart: unless-stopped

This configuration works perfectly fine except it doesn’t have a static IP. The PMS mac address is set correctly and the IP address is automatically assigned to the first IP in the available range of the macvlan but I want the IP to be static so when I add new containers to the network or have to rebuild this for whatever reason the IP won’t change. Everything I’ve seen so far says to add a static IP the config should look like this:

networks:
    my_macvlan:
         ipv4_address: 192.168.1.200

However, I can’t get this to work. I get an error saying that the ipv4_address flag is not a regexes. Looking at the plexinc/pms-docker page, it says there is a flag that can be used to set the IP address, --ip=<IPAddress>, when using macvlan networking but I can’t figure out how to convert that to docker-compose.

I would appreciate any help getting this configuration right.

Thanks,

I figured out how to get this to work after a little more research on the r/portainer Reddit. The first thing I had to change was not to use “network_mode:” because it can’t be used with “networks:” at the same time. I had to define my existing macvlan network in a separate block than the services block that creates the plex container and flag it as external. Then, I could use the “ipv4_address:” flag to set my static IP like in the first post. I’ll put the final docker-compose config below.

##PLEX_MEDIA_SERVER##
---
version: "3.0"

services:
  plex:
    image: plexinc/pms-docker:plexpass
    container_name: plex_docker
    mac_address: 02:42:c0:a8:01:c8
    hostname: pms
    environment:
      - NVIDIA_VISIBLE_DEVICES=all
      - PUID=1000
      - PGID=1000
      - VERSION=docker
      - TZ=America/Chicago
      - UMASK_SET=022 #optional
    volumes:
      - /home/containers/plex:/config
      - /media/Video/TV:/tv
      - /media/Video/Movies:/movies
      - /media/Video/3D:/3D
      - /media/Music:/music
    restart: unless-stopped
    networks:
      my_macvlan:
        ipv4_address: 192.168.1.200
        
networks:
  my_macvlan:
    external:
      name: my_macvlan

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.