title: customizing docker bridge network
body: <p>I want my docker0 and all containers to have the same gateway address or be in the same IPrange as my local machine. I started by defining a fixed-cidr in ther daemon.json file <code>/etc/docker/daemon.json</code></p>
  
  <pre><code>{
    "bip": "10.80.44.248/24",
    "fixed-cidr": "10.80.44.250/25",
    "mtu": 1500,
    "default-gateway": "10.80.44.254",
    "dns": ["10.80.41.14"]
  }
  </code></pre>
  
  <p>It seems to be working looking at the output of the <code>ip -a</code>
  It seems the docker0 has never received any data since.</p>
  
  <pre><code>docker0: flags=4099&lt;UP,BROADCAST,MULTICAST&gt;  mtu 1500
          inet *10.80.44.248*  netmask 255.255.255.0  broadcast *10.80.44.255*
          ether 02:42:9c:b9:e1:63  txqueuelen 0  (Ethernet)
          RX packets 0  bytes 0 (0.0 B)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 0  bytes 0 (0.0 B)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  
  ens192: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
          inet *10.80.44.39*  netmask 255.255.255.0  broadcast *10.80.44.255*
          inet6 fe80::250:56ff:feb1:79e4  prefixlen 64  scopeid 0x20&lt;link&gt;
          ether 00:50:56:b1:79:e4  txqueuelen 1000  (Ethernet)
          RX packets 211061  bytes 30426474 (29.0 MiB)
          RX errors 0  dropped 33861  overruns 0  frame 0
          TX packets 3032  bytes 260143 (254.0 KiB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  </code></pre>
  
  <p>The local machine and the docker0 are in same IP range with the same gateway. Good.
  But when I start the docker containers and inspected the bridge settings Everything was different. This is the output of </p>
  
  <pre><code>docker network inspect bridge
  
  
  [
      {
          "Name": "bridge",
          "Id": "b326a37a589245449e1268bbb9ee65262eb7986574c0e972c56d350aa82d7238",
          "Created": "2018-04-04T03:25:52.00544539+02:00",
          "Scope": "local",
          "Driver": "bridge",
          "EnableIPv6": false,
          "IPAM": {
              "Driver": "default",
              "Options": null,
              "Config": [
                  {
                      "Subnet": "10.80.44.248/24",
                      "IPRange": "10.80.44.128/25",
                      "Gateway": "10.80.44.248",
                      "AuxiliaryAddresses": {
                          "DefaultGatewayIPv4": "10.80.44.254"
                      }
                  }
              ]
          },
          "Internal": false,
          "Attachable": false,
          "Ingress": false,
          "ConfigFrom": {
              "Network": ""
          },
          "ConfigOnly": false,
          "Containers": {},
          "Options": {
              "com.docker.network.bridge.default_bridge": "true",
              "com.docker.network.bridge.enable_icc": "true",
              "com.docker.network.bridge.enable_ip_masquerade": "true",
              "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
              "com.docker.network.bridge.name": "docker0",
              "com.docker.network.driver.mtu": "1500"
          },
          "Labels": {}
      }
  ]
  </code></pre>
  
  <p>I don't understand why now IPAM config is having a IPv4 als auxiliary</p>
  
  <p>"AuxiliaryAddresses": {
                          "DefaultGatewayIPv4": "10.80.44.254"
                      }</p>
  
  <p>I realised that now the bridge is not created from the same subnet as it was configured by the <code>daemon</code> I it created 2 different bridges with different IP ranges. That is still the default from docker.</p>
  
  <blockquote>
    <p>docker network ls</p>
  </blockquote>
  
  <pre><code>NETWORK ID          NAME                   DRIVER              SCOPE
  b326a37a5892        bridge                 bridge              local
  6ce11066cdea        dockergitlab_default   bridge              local
  d5a36c04b809        host                   host                local
  15f66b88ee67        none                   null                local
  </code></pre>
  
  <blockquote>
    <p>docker network inspect dockergitlab_default</p>
  </blockquote>
  
  <pre><code>[
      {
          "Name": "dockergitlab_default",
          "Id": "6ce11066cdeabf3cfe65b2dff22046bd1e9c18d2588f47b9cd3c52ea24f7a636",
          "Created": "2018-03-14T08:56:23.351051727+01:00",
          "Scope": "local",
          "Driver": "bridge",
          "EnableIPv6": false,
          "IPAM": {
              "Driver": "default",
              "Options": null,
              "Config": [
                  {
                      "Subnet": "172.17.0.0/16",
                      "Gateway": "172.17.0.1"
                  }
              ]
          },
          "Internal": false,
          "Attachable": true,
          "Ingress": false,
          "ConfigFrom": {
              "Network": ""
          },
          "ConfigOnly": false,
          "Containers": {
              "60f769c91cff1de47794a7c8b587b778488883da094ae32cfde5196ee0f528f1": {
                  "Name": "gitlab-runner",
                  "EndpointID": "5122fe862537fb8434a484b4797153274b945e20bc3c7223efc6fd0bd55eae14",
                  "MacAddress": "02:42:ac:11:00:04",
                  "IPv4Address": "172.17.0.4/16",
                  "IPv6Address": ""
              },
              "9c46e1fde6390142bddf67270cfeda7b3e68b1a6e68cabc334046db687240a8d": {
                  "Name": "dockergitlab_postgresql_1",
                  "EndpointID": "8488b32cc34a2c92308528de74b5eddcecac12a402ee6e67c1ef0f2750b72721",
                  "MacAddress": "02:42:ac:11:00:03",
                  "IPv4Address": "172.17.0.3/16",
                  "IPv6Address": ""
              },
              "eaf29f5f405cbf9bdd918efad26ceae1a8c3f58f4bef0aa8fd86b4631bcfdf43": {
                  "Name": "dockergitlab_gitlab_1",
                  "EndpointID": "d7f78ee9bd51dd13826d7834470d03a9084fc7ab8c6567c0181acecc221628c6",
                  "MacAddress": "02:42:ac:11:00:02",
                  "IPv4Address": "172.17.0.2/16",
                  "IPv6Address": ""
              },
              "f460687ec00eff214fa08adfe9a0af5b85c392ceb470c4ed630ef7ecb0bfcba1": {
                  "Name": "dockergitlab_redis_1",
                  "EndpointID": "8b18906f1c79a5faaadd32afdef20473f9b635e9a1cd2c7108dd98df48eaed86",
                  "MacAddress": "02:42:ac:11:00:05",
                  "IPv4Address": "172.17.0.5/16",
                  "IPv6Address": ""
              }
          },
          "Options": {},
          "Labels": {
              "com.docker.compose.network": "default",
              "com.docker.compose.project": "dockergitlab"
          }
      }
  ]
  </code></pre>
  
  <p>I have no idea why the docker bridge is now created with the old default ip address.</p>
  
  <blockquote>
    <p>LOCAL SYSTEM Details</p>
  </blockquote>
  
  <p>I can do <code>apt update</code> on the local machine but when i logged into the gitlab-runner i can't do <code>apt update</code></p>
  
  <pre><code>Linux  4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64
  
  Docker version 17.12.0-ce, build c97c6d6
  
  docker-compose version 1.18.0, build 8dd22a9
  </code></pre>
  
  <p>Is there a way I can oveeride the bridge settings. From what i have read, when I define/configure the cdir and gateway in daemon.json file everything will be taken from there for the creation of the bridge network and all other containers.</p>
  
  <p>Thanks in Advance for your help. </p>