0

I have a docker container I would like to access from other clients on the LAN. I do not want to access them via the docker host's IP and bind container ports to host ports. I would like to access the container via its own IP address as if it was an independent physical device on the LAN itself.

It seems that the macvlan network is the way to do this. I created a macvlan network like so:

 docker network create -d macvlan \
--subnet=192.168.1.0/24 \
--gateway=192.168.1.1 \
 -o parent=eth0 network_macvlan

where eth0 is the network interface on the host and the --gateway IP is pointing to the router's gateway IP. Then in my docker-compose.yml file I am declaring the network just created as external, and creating the service:

networks:
  network_macvlan:
    external: true

services:
  jellyfin:
    image: lscr.io/linuxserver/jellyfin:latest
    container_name: jellyfin
    environment:
      - PUID=1000
      - PGID=1000
    volumes:
      - /jellyfin-config:/config
      - /Series:/data/tvshows
      - /Movies:/data/movies
    ports:
      - 8096:8096
    networks:
      network_macvlan:
       ipv4_address: 192.168.1.20
    restart: unless-stopped

Next I run the service with docker-compose up -d jellyfin, and I know the service is correctly assigned the IP address since running docker inspect network_macvlan shows:

 "Containers": {
            "adcf094a88fe4e70ece4fa8df7e3766605b0edb25da29563": {
                "Name": "jellyfin",
               "EndpointID": "77c533fcd084caf388c91dfe33d1abe8a1f9fb4ba099c10243be4b85e",
                "MacAddress": "02:42:c0:a8:01:14",
                "IPv4Address": "192.168.1.20/24",
                "IPv6Address": ""
            }
        }, ...

The Problem is that I cannot access this IP address from other clients on the LAN.

  1. ping 192.168.1.20: shows Request timeout for icmp_seq
  2. MAC address not showing up in the router's gateway web app

What am I missing here?

I also tried creating the network on eth0.50 instead of eth0 as a trunked bridge example in the official docs but did not solve the issue.

bcsta
  • 1,963
  • 3
  • 22
  • 61
  • Have you managed to find a solution?. The closest thing that i got to is: https://stackoverflow.com/questions/74377630/docker-bridge-network-with-public-ip-addresses-same-level-as-host-machine – 0x4139 Nov 09 '22 at 15:50

1 Answers1

0

Have you tried setting your interface to promiscuous mode. Use:

ip link set eth1 promisc on