Last active
March 18, 2024 22:21
-
-
Save MParvin/cfb3ed0b6e17b2fb9650850e40151e2c to your computer and use it in GitHub Desktop.
Resolve docker dns problem, with remove bridge and restart docker, I used this answer: https://serverfault.com/a/642984
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
install_brctl_in_debian(){ | |
apt update && apt install -y bridge-utils && \ | |
} | |
install_brctl_in_rhell(){ | |
yum makecache && yum install -y bridge-utils && \ | |
} | |
remove_bridge(){ | |
systemctl stop docker docker.socket && \ | |
pkill docker && \ | |
iptables -t nat -F && \ | |
ifconfig docker0 down && \ | |
brctl delbr docker0 && \ | |
systemctl start docker | |
} | |
detect_os(){ | |
dist_name=`. /etc/os-release && echo "$ID"`; | |
echo $dist_name | |
} | |
if [[ $(uname -s) -eq 'Linux' ]]; then | |
lsb_dist=$(detect_os) | |
else | |
echo "currently just support Linux" && exit 1 | |
fi | |
(echo $lsb_dist | grep -iE 'ubuntu|debian' &>/dev/null && install_brctl_in_debian) || \ | |
(echo $lsb_dist | grep -iE 'centos|fedora' && install_brctl_in_rhell ) || \ | |
(echo "This distribution doest not supported" && exit 1) | |
remove_bridge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment