The Problem
===========

I have recently created a docker container that has to pull a public github repository, however, it isn't able to resolve the host github.com. In fact, it isn't able to even execute ping command.

**NOTE: all network operations here are inside the container after building, when the container runs**

`ping www.google.com` gives `cannot resolve host`

It cannot connect to the internet at all.

After looking on the internet and [Docker Documentation](https://docs.docker.com/engine/install/linux-postinstall/#ip-forwarding-problems)

Solutions Tried
===============

1) Enabling IP Forwarding as given in [Docker Documentation](https://docs.docker.com/engine/install/linux-postinstall/#ip-forwarding-problems)
----------------------------------------------------------------------------------------------------------------------------------------------

I tried enabling IPForwarding but to no avail.

Contents of `/usr/lib/systemd/network/80-container-host0.network` after enabling IPForwarding

```
...
[Network]
DHCP=yes
LinkLocalAddressing=yes
LLDP=yes
EmitLLDP=customer-bridge
IPForward=true // this line was changed
[DHCP]
UseTimezone=yes

```

2) Recreating Docker Bridge as given in [Stack Overflow](https://superuser.com/a/1130993/1214210)
-------------------------------------------------------------------------------------------------

```
pkill docker
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
sudo service restart docker

```

This was originally effective in [this issue](https://github.com/moby/moby/issues/866#issuecomment-19218300)

There is a solution for ubuntu, but my network configuration doesn't have that [problematic](https://superuser.com/a/1274161/1214210) line

my `sudo pico /etc/NetworkManager/NetworkManager.conf` is just filled with comments

```
[main]
#plugins=ifcfg-rh

[logging]
#level=TRACE
#domains=ALL

```

3) Installing IP-Tables service [StackOverflow](https://stackoverflow.com/a/60074328/2851473)
---------------------------------------------------------------------------------------------

```
sudo yum install iptables-services
sudo service docker restart

```

4) Overriding DNS configuration in docker-compose-[StackOverflow](https://stackoverflow.com/questions/41717180/docker-compose-container-using-host-dns-server)
--------------------------------------------------------------------------------------------------------------------------------------------------------------

```
version: "3.3"
services:
    airflow:
        build: 
            context: ./airflow
            dockerfile: Dockerfile
        ports: 
            - 8080:8080
        environment: 
            GITHUB_DAG_REPO: https://github.com/siddharths067/HelloAirflow.git
        dns:
            - 8.8.8.8
            - 8.8.4.4

```

The Docker Network Inspect of the Image's Network
=================================================

I don't know if this would be of any use

```
docker network inspect airflowsetup_default 
[
    {
        "Name": "airflowsetup_default",
        "Id": "141a518c1440e603f75774c54f42de33e9173e3f062a0a0bc772db13a7f1ef5d",
        "Created": "2020-08-30T14:42:30.951975699+05:30",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.18.0.0/16",
                    "Gateway": "172.18.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": true,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {},
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "default",
            "com.docker.compose.project": "airflowsetup",
            "com.docker.compose.version": "1.25.4"
        }
    }
]

```

### Output

```
airflow_1  | GITHUB DAG REPO IS
airflow_1  | https://github.com/siddharths067/HelloAirflow.git
airflow_1  | Cloning into 'HelloAirflow'...
airflow_1  | fatal: unable to access 'https://github.com/siddharths067/HelloAirflow.git/': Could not resolve host: github.com

```