Bridge network missing Gateway – Docker Issue

Here is a little something for you.  I’m working on building a demo of Oracle GoldenGate Microservices between three (3) containers. In order to do this, I wanted to setup a dedicated network between the containers.

In order to setup a dedicated network, I needed to configure a network for the containers to use.  Docker makes this quite easy with he usage of docker network create (here).

Before creating my network, by using docker network ls I can quickly see what networks have been defined on my local machine:

bocurtis-Mac:GG19c bocurtis$ docker network ls
NETWORK ID NAME DRIVER SCOPE
c9af13c37029 bridge bridge local
0a9b2554201f host host local
6686aa820e6d none null local

Although the bridge network is there, this network only allows you to reference containers by their IP address.  Not a fun thing to remember.  By creating my own bridge network, I can then specify that containers by name.  Which will make my life a lot easier. 

To create my network, I ran the following command:

bocurtis$ docker network create --driver=bridge --subnet=192.168.0.0/16 GoldenGateNet

After creating the network, make sure the network is now in the list of avaliable networks:

bocurtis-Mac:GG19c bocurtis$ docker network ls
NETWORK ID NAME DRIVER SCOPE
5a6a703615ee GoldenGateNet bridge local
c9af13c37029 bridge bridge local
0a9b2554201f host host local
6686aa820e6d none null local

Afterwards, I did an docker inspect on the network to make sure everything was configured as I expected:

bocurtis-Mac:GG19c bocurtis$ docker inspect network GoldenGateNet
[
{
"Name": "GoldenGateNet",
"Id": "49a28b4c03552237363cf1ddd8e2e0eecab66e898785f36b8c21270487899052",
"Created": "2019-11-03T17:33:29.398023638Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "192.168.0.0/16"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {},
"Labels": {}
}
]

Something to notice here, besides the text formatting fo the JSON.  That is the Config only has a subnet listed and there is no gateway.  This is a big problem because you can route between boxes, but not to the internet.  So do we fix this? 

You can always drop the network and recreate the network and provide the —gateway option; however, before doing that, simply restart the docker daemon.  When you go to restart the daemon, on Mac anyways, you will be prompted.  Say OK to have the daemon restart.

dockerdaemonrestart.png

 

One the docker daemon is restarted, then you can do a docker inspect network again.  This time the configuration should be correct and have  a gateway for the network.

bocurtis-Mac:GG19c bocurtis$ docker inspect network GoldenGateNet
[
{
"Name": "GoldenGateNet",
"Id": "49a28b4c03552237363cf1ddd8e2e0eecab66e898785f36b8c21270487899052",
"Created": "2019-11-03T17:33:29.398023638Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "192.168.0.0/16",
"Gateway": "192.168.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {},
"Labels": {}
}
]

Now, just attach your container to the network and ensure that you have access to the internet and between containers.

Enjoy and God bless!!!

Please follow and like:

Enquire now

Give us a call or fill in the form below and we will contact you. We endeavor to answer all inquiries within 24 hours on business days.