-
-
Save justineuro/56d57c78611dcf6411223b5018789080 to your computer and use it in GitHub Desktop.
Flush IP tables and restart docker
This file contains 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 | |
# From: https://gist.github.com/mrclay/da1a83380371ee15ae02b4bcc3db8da1 | |
# * addedd '#' in line 1; source and comments in lines 3-4 | |
# Script is needed because my default firewall rules are messed up and after | |
# every restart, docker containers can't make connections to the host, notably | |
# preventing debuggers like xdebug from attaching. | |
set -euo pipefail | |
# Unless docker is stopped with no containers running, docker will leave zombie | |
# proxy processes that hold the ports open preventing the start of new containers. | |
# If this happens I have to kill them manually: https://stackoverflow.com/a/61239636/3779 | |
if [ ! $(docker ps | wc -l) == "1" ]; then | |
echo "Some docker containers are running." | |
exit 0 | |
fi | |
sudo service docker stop | |
sudo iptables -P INPUT ACCEPT | |
sudo iptables -P FORWARD ACCEPT | |
sudo iptables -P OUTPUT ACCEPT | |
sudo iptables -t nat -F | |
sudo iptables -t mangle -F | |
sudo iptables -F | |
sudo iptables -X | |
sudo service docker start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment