Skip to content

Instantly share code, notes, and snippets.

@MParvin
Last active March 18, 2024 22:21
Show Gist options
  • Save MParvin/cfb3ed0b6e17b2fb9650850e40151e2c to your computer and use it in GitHub Desktop.
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
#!/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