Connection between host and container with own ip

hi,

I use docker on a debian 10 host with IP 192.168.10.10 and i use containers:

  • with own ip like 192.168.10.20 - 30 (I use a network with macvlan driver)
  • without ip like 172.17.0.2 or 172.31.0.3

Now I have a problem with connection between the host and my container with 192.168.10.* ip. F.e. I can ping the container with ip 192.168.10.20 from other hosts like 192.168.10.5 but not from 192.168.10.10.

I found information about routing between host and containers. But I’ve still no clue how to solve this.

#> cat /etc/network/interfaces
auto lo
iface lo inet loopback

iface eno1 inet manual

auto vmbr0
iface vmbr0 inet static
    address 192.168.10.60
    netmask 255.255.255.0
    gateway 192.168.10.1
    network 192.168.10.0
    broadcast 192.168.10.255
    dns-nameservers 192.168.10.1
    bridge_ports eno1
    bridge_stp off
    bridge_fd 0

Don’t wounder about the vmbr0 device. On this machine is also running proxmox.

Thank you for you attention.
a200.

You might want to check this thread:

Thank you for the answer. In this case, what is the best way to create a container with his own ip (different from the host-ip) which can be accessed from other devices in my 192.168.10.0/24 network? is this not the default use-case for docker?

The default use case is to use overlay or bridged networks and publish ports.

Containers interacting with each orther need to be in the same docker network. Access from outside is usualy done using load balancers that listen on a subdomain and forward the traffic to publised ports.

Usualy people asking for macvlan are trying to treat docker containers like vms…

At the end your use case dictates what is required. The earlier posted link has a link to a blog post that discusses how the setup needs to look like in order to permit communication between the docker node and containers.

You might want to share how you create your macvlan network. Be sure to use a subnet CIDR inside the range CIDR that is excluded from the LAN’s dhcp server to prevent ip collisions.