Docker Bridge Network Seems to Disable Host Network

Overview
Greetings. I am having difficulty configuring my docker network for my specific application. Presently, my configuration disables incoming pings from another host machine on the subnet.

Details
I have a small network with two computers, the subnet of which is 192.168.127.0/24. The Docker host has an IP address of 192.168.127.101. A minimally reproduceable YAML file for docker-compose shows my configuration:

version: '3.1'

services:
  my-service:
    image: ubuntu:20.04
    privileged: true
    stdin_open: true
    tty: true
    command: /bin/bash
    networks:
      system_net:
        ipv4_address: 192.168.127.102
networks:
  system_net:
    driver: bridge
    ipam:
      config:
        - subnet: 192.168.127.0/24
          gateway: 192.168.127.1

The rationale for this configuration is: I require an assignable static IP address for the container that shares the same subnet as the host’s network. Furthermore, I need to be able to ping (from within the container) ethernet devices wired to the host’s NIC. The above configuration allows this. However, when I attempt to ping the Docker host from the other machine on the subnet, I get “Destination Host Unreachable”. The moment I bring down the container, the pings from the remote host work.

Any ideas?

You might want to use the forum search with the search term “macvlan”. A macvlan network can be bridged into your existing lan and interact with it, as if it would be a standalone device. A bridge network creates a private natted network. The search results should yield more information on the topic.

2 Likes

Thank you, @meyay! I ended up resolving my problem as suggested with a macvlan solution.