Home  >  Q&A  >  body text

Network - Docker for Mac container IP configuration problem

  1. Host Mac related information

    en0: inet 192.168.2.117 netmask 0xffffff00 broadcast 192.168.2.255
  2. Docker for Mac related information

    # ip addr show eth0
    4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether c0:ff:ee:c0:ff:ee brd ff:ff:ff:ff:ff:ff
        inet 192.168.65.2/29 brd 192.168.65.7 scope global eth0
  3. Create macvlan network and container

    docker network create -d macvlan --subnet=192.168.2.0/24 --gateway=192.168.2.1  -o parent=eth0 pub_net
    
    docker run --net=pub_net --ip=192.168.2.130 -itd centos /bin/sh
  4. Enter the container to view network information

    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.2.130  netmask 255.255.255.0  broadcast 0.0.0.0
            inet6 fe80::42:c0ff:fea8:282  prefixlen 64  scopeid 0x20<link>
            ether 02:42:c0:a8:02:82  txqueuelen 0  (Ethernet)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 9  bytes 718 (718.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    Question: I cannot access the Internet in the container. Is there something wrong with broadcast 0.0.0.0? My purpose is to assign the container an IP in the same network segment as the host. I am begging for answers. . .

大家讲道理大家讲道理2716 days ago1219

reply all(1)I'll reply

  • 阿神

    阿神2017-06-05 11:10:30

    Why is the wooden man coming? I'm going crazy

    reply
    0
  • Cancelreply