Last active
September 30, 2019 09:59
-
-
Save Eidansoft/8a61fe10f8d65a43608ea680ad717d61 to your computer and use it in GitHub Desktop.
Docker tips
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
# On a docker container force to not reach Internet/connectivity | |
# The docker must be started as a privileged with the param --privileged and | |
# on the running container, you must have iptables installed (apt-get install iptables), | |
# then you can run: | |
# To avoid all connectivity at all | |
iptables -A OUTPUT -j DROP | |
# Avoid all connectivity on a specific interface | |
iptables -A OUTPUT -o eth1 -j DROP | |
# Avoid connectivity to a specific IP | |
iptables -A INPUT -s 1.2.3.4 -j DROP | |
# If the restriction must be for a specific port (for example 25), then: | |
iptables -A INPUT -s 1.2.3.4 -p tcp --destination-port 25 -j DROP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment