github.com/walkingsparrow/docker@v1.4.2-0.20151218153551-b708a2249bfa/docs/userguide/networking/default_network/custom-docker0.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Customize the docker0 bridge"
     4  description = "Customizing docker0"
     5  keywords = ["docker, bridge, docker0, network"]
     6  [menu.main]
     7  parent = "smn_networking_def"
     8  +++
     9  <![end-metadata]-->
    10  
    11  # Customize the docker0 bridge
    12  
    13  The information in this section explains how to customize the Docker default bridge. This is a `bridge` network named `bridge` created automatically when you install Docker.  
    14  
    15  **Note**: The [Docker networks feature](../dockernetworks.md) allows you to create user-defined networks in addition to the default bridge network.
    16  
    17  By default, the Docker server creates and configures the host system's `docker0` interface as an _Ethernet bridge_ inside the Linux kernel that can pass packets back and forth between other physical or virtual network interfaces so that they behave as a single Ethernet network.
    18  
    19  Docker configures `docker0` with an IP address, netmask and IP allocation range. The host machine can both receive and send packets to containers connected to the bridge, and gives it an MTU -- the _maximum transmission unit_ or largest packet length that the interface will allow -- of 1,500 bytes. These options are configurable at server startup:
    20  
    21  - `--bip=CIDR` -- supply a specific IP address and netmask for the `docker0` bridge, using standard CIDR notation like `192.168.1.5/24`.
    22  
    23  - `--fixed-cidr=CIDR` -- restrict the IP range from the `docker0` subnet, using the standard CIDR notation like `172.167.1.0/28`. This range must be an IPv4 range for fixed IPs (ex: 10.20.0.0/16) and must be a subset of the bridge IP range (`docker0` or set using `--bridge`). For example with `--fixed-cidr=192.168.1.0/25`, IPs for your containers will be chosen from the first half of `192.168.1.0/24` subnet.
    24  
    25  - `--mtu=BYTES` -- override the maximum packet length on `docker0`.
    26  
    27  Once you have one or more containers up and running, you can confirm that Docker has properly connected them to the `docker0` bridge by running the `brctl` command on the host machine and looking at the `interfaces` column of the output.  Here is a host with two different containers connected:
    28  
    29  ```
    30  # Display bridge info
    31  
    32  $ sudo brctl show
    33  bridge name     bridge id               STP enabled     interfaces
    34  docker0         8000.3a1d7362b4ee       no              veth65f9
    35                                                          vethdda6
    36  ```
    37  
    38  If the `brctl` command is not installed on your Docker host, then on Ubuntu you should be able to run `sudo apt-get install bridge-utils` to install it.
    39  
    40  Finally, the `docker0` Ethernet bridge settings are used every time you create a new container.  Docker selects a free IP address from the range available on the bridge each time you `docker run` a new container, and configures the container's `eth0` interface with that IP address and the bridge's netmask.  The Docker host's own IP address on the bridge is used as the default gateway by which each container reaches the rest of the Internet.
    41  
    42  ```
    43  # The network, as seen from a container
    44  
    45  $ docker run -i -t --rm base /bin/bash
    46  
    47  $$ ip addr show eth0
    48  24: eth0: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    49      link/ether 32:6f:e0:35:57:91 brd ff:ff:ff:ff:ff:ff
    50      inet 172.17.0.3/16 scope global eth0
    51         valid_lft forever preferred_lft forever
    52      inet6 fe80::306f:e0ff:fe35:5791/64 scope link
    53         valid_lft forever preferred_lft forever
    54  
    55  $$ ip route
    56  default via 172.17.42.1 dev eth0
    57  172.17.0.0/16 dev eth0  proto kernel  scope link  src 172.17.0.3
    58  
    59  $$ exit
    60  ```
    61  
    62  Remember that the Docker host will not be willing to forward container packets out on to the Internet unless its `ip_forward` system setting is `1` -- see the section on [Communicating to the outside world](container-communication.md#communicating-to-the-outside-world) for details.