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
Solutions Tried
1) Enabling IP Forwarding as given in Docker Documentation
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
pkill docker
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
sudo service restart docker
This was originally effective in this issue
There is a solution for ubuntu, but my network configuration doesn't have that problematic 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
sudo yum install iptables-services
sudo service docker restart
4) Overriding DNS configuration in docker-compose-StackOverflow
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