Skip to content

Instantly share code, notes, and snippets.

@MrChrisWeinert
Last active July 5, 2022 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrChrisWeinert/274d487d9e626262d879691b4ddc90d2 to your computer and use it in GitHub Desktop.
Save MrChrisWeinert/274d487d9e626262d879691b4ddc90d2 to your computer and use it in GitHub Desktop.
Just a collection of stuff I use to troubleshoot Docker and networking issues
#Stop/Remove a specific Docker Container
docker stop containername && docker rm containername
#Stop all containers with "backend" in it:
docker rm $(docker ps -a | grep backend | cut -f1 -d' ')
#Stop all Docker Containers
docker stop $(docker ps -aq)
#Remove all Docker Containers
docker rm $(docker ps -aq)
#To capture TCP data from a Docker Container
IP=`docker inspect containername | grep 'IPAddress":' | cut -f4 -d'"' | head -1` && sudo tcpdump -i docker0 host $IP
#Show all iptables rules
sudo iptables -L
#Show all iptables rules with line numbers
sudo iptables -L --line-numbers
#To delete a rule, do a -D followed by the Chain name (INPUT) followed by the line number (3)
sudo iptables -D INPUT 3
#Turn off iptables (do this all on one line, or else your SSH session will die)
sudo iptables -F && sudo iptables -X && sudo iptables -P INPUT ACCEPT && sudo iptables -P OUTPUT ACCEPT && sudo iptables -P FORWARD ACCEPT
#Persist current firewall settings by saving them here
iptables-save > /etc/iptables/rules.v4
#Save current firewall rules to a file
sudo iptables-save > fw.rules
#Restore firewall rules from a file
sudo iptables-restore fw.rules
#Hand-edit firewall rules here:
sudo vi /etc/iptables/rules.v4
#SCP a file from my local machine to a remote one:
scp ciscat-full-bundle-2019-09-25-v3.0.61.zip username@remotehost:ciscat-full-bundle-20
19-09-25-v3.0.61.zip
#SCP a file from a remote machine to my mine:
scp user@remotehost:cis-cat-full/results/filename.html filename.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment