0

tl;dr I want every container in this stack to use the same IP & MAC address and be on my local network but need help on how to

For starters I'm new to docker and docker-compose. I made a docker-stack for my Plex Servers (three of them, one for movies by general categories/tv-shows, music, and holidays) with each one having its own IP address & MAC on my local network and now I want to make a second stack for some of my media management tools but this time I'd like the whole stack to use one IP address and MAC address but I haven't been able to figure out how to do it correctly/so it works This is running on a QNAP NAS (TVS1282v3/QTS) but I am working through the CLI as I leaned that if I do a docker-compose through container station that it won't create the network for me

version: '2.4'

services:
  Sonarr:
    image: linuxserver/sonarr
    container_name: Sonarr
    environment:
      - TZ=AMERICA/Denver
      - name= Sonarr
    volumes:
      - /share/MediaManagement/Sonarr/config:/config:rw
      - /share/MediaManagement/rip:/rip:rw
      - /share/Plex:/Plex:rw
    ports:
      - 8989:8989
    restart: unless-stopped

  Radarr:
    image: linuxserver/radarr
    container_name: Radarr
    environment:
      - TZ=AMERICA/Denver
      - name= Radarr
    volumes:
      - /share/MediaManagement/Radarr/config:/config:rw
      - /share/MediaManagement/rip:/rip:rw
      - /share/Plex:/Plex:rw
    ports:
      - 7878:7878
    restart: unless-stopped

  Lidarr:
    image: linuxserver/lidarr
    container_name: Lidarr
    hostname: Lidarr
    environment:
      - TZ=AMERICA/Denver
      - name= Lidarr
    volumes:
      - /share/MediaManagement/Lidarr/config:/config:rw
      - /share/MediaManagement/rip:/rip:rw
      - /share/Plex:/Plex:rw
    ports:
      - 8686:8686
    restart: unless-stopped

  networks:
    qnet-static:
      ipv4_address: 192.168.2.100
    mac_address: 05:4A:AA:08:51:43
    
networks:
  qnet-static:
    driver: qnet
    ipam:
      driver: qnet
      options:
        iface: "eth0"
      config:
        - subnet: 192.168.2.0/23
          gateway: 192.168.2.1

I have also tried it like how it was set up in my Plex compose file where I put

services:
  NameOfService:
    mac_address: 05:4A:AA:08:51:43
    networks:
      qnet-static:
        ipv4_address: 192.168.2.100
....
networks: ##At the end, not in each service##
  qnet-static:
    driver: qnet
    ipam:
      driver: qnet
      options:
        iface: "eth0"
      config:
        - subnet: 192.168.2.0/23
          gateway: 192.168.2.1

in each service but only the first container worked....

I also tried this at one point but still no luck/ it's syntax is wrong

networks:
  qnet-static:
    driver: qnet
    ipam:
      driver: qnet
      options:
        iface: "eth0"
      config:
        - subnet: 192.168.2.0/23
          gateway: 192.168.2.250
    ipv4_address: 192.168.2.100
  mac_address: 05:4A:AA:08:51:43

Any help would be appreciate it as I am probably just missing a minor piece

LostChild
  • 11
  • 1
  • 2

1 Answers1

0

Delete absolutely all of the networks: settings in the file. Don't try to manually assign IP address to containers or configure their MAC addresses.

Your containers will be accessible on your host's IP address, using the first ports: number for each. As far as other hosts on your network are concerned, the processes in containers will be indistinguishable from other services not running in containers.

You also do not need to manually set container_name: or hostname: in most circumstances. There are additional details of the Compose networking environment in Networking in Compose in the Docker documentation, though this mostly focuses on connections between containers. You usually don't need to think about the container-private IP address or (especially) the artificial MAC address within the container network environment.

David Maze
  • 130,717
  • 29
  • 175
  • 215
  • Thank you for you're response David! I'd like to be able to set the stack to a manual IP as I do at times have a another service running on the assigned port (I know I can change what port sits assigned to) and I know I don't have to have a MAC assigned but I'd prefer to have the whole stack use an assigned IP/MAC as at times I'd like to spin up a second container of the same image for testing. Part of this is for my own personal knowledge to learn different things I can do with docker. If what I'm asking is not possible please let me know but I'd love to learn how if it is possible! – LostChild Jan 13 '21 at 02:19
  • Usually the only conflict is around `ports:` (assuming you don't manually specify things like `container_name:`); manually setting container IP address won't affect the conflict for host ports. If the host had multiple NICs or IP aliases you could set `ports:` to bind to a specific host IP. But in this way a container acts a little more like a process, which (externally) doesn't usually have its own IP address. – David Maze Jan 13 '21 at 02:30