#!/bin/bash # Simple DNS fix that you can run with sudo # Usage: sudo ./fix-dns-now.sh set -e if [ "$EUID" -ne 0 ]; then echo "This script must be run as root (use sudo)" exit 1 fi echo "Fixing DNS configuration..." # Backup existing resolv.conf if [ -f /etc/resolv.conf ]; then cp /etc/resolv.conf /etc/resolv.conf.backup.$(date +%Y%m%d_%H%M%S) echo "✓ Backed up existing resolv.conf" fi # Create new resolv.conf with reliable DNS servers cat > /etc/resolv.conf < /etc/wsl.conf < /dev/null 2>&1; then echo "✓ DNS resolution working!" else echo "⚠ DNS test failed, but configuration is updated" echo "You may need to restart WSL or Docker Desktop" fi echo "" echo "Done! Try running your Docker commands again." echo "If issues persist, restart Docker Desktop or run: wsl --shutdown (from Windows)"