larsks / docker-image-logitech-media-server

MIT License
33 stars 74 forks source link

Preventing port clash by using macvlan - howto #21

Open time4tea opened 5 years ago

time4tea commented 5 years ago

Hi,

I also want to use plex on the same box that runs LMS, and so cannot use host networking - which was the easiest networking mode to get working - because of port clash. The default bridge networking mode seemed to advertise the container IP address of 172.xxx.xxx.xxx which seemed to defeat autodiscovery.

Anyhow, I managed to get macvlan networking working, so thought others may appreciate an example.

# The "init:" keyword, below, requires either version "2.2"
# or "2.3".
version: "2.3"

services:
  squeeze:
    image: larsks/logitech-media-server:7.9
    hostname: media
    networks:
      squeezebridge:
        ipv4_address: 192.168.0.96

    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /data/squeeze:/srv/squeezebox
      - /data/share/mp3:/srv/music
    ports:
      - "9000:9000"
      - "9090:9090"
      - "3483:3483"
      - "3483:3483/udp"
    restart: always
    init: true

networks:
  squeezebridge:
    driver: macvlan
    driver_opts:
      parent: eno1
    ipam:
      config:
        - subnet: 192.168.0.0/24
          gateway: 192.168.0.1
          ip_range: 192.168.0.96/32

The host has an ethernet interface eno1, and the subnet and gateway settings are the same as for that interface. The ipv4_address and ip_range settings are the ip address that the LMS server should be assigned. The ip_range needs to be a CIDR value. Strictly speaking I suppose ip range as a /32 isn't required, but i stopped fiddling when it started working!

Thanks for making this nice docker image.

Cheers

James

larsks commented 5 years ago

James,

Thanks for the note! That's great information. I think I'll add this to the README.