Method | Docker iptables setting | Firewall on? | Accessible from local network |
---|---|---|---|
docker run --network=host -p 3306:3306 |
false |
No | Yes |
docker run --network=host -p 3306:3306 |
false |
Yes | No |
docker run -p 3306:3306 |
Default | Yes | |
docker run -p 127.0.0.1:3306:3306 |
Default | Yes | No |
An alternative option would be to leave the Docker iptables
as the default, leave the firewall on, and modify iptables itself à la https://stackoverflow.com/a/51741599/399105
Method | Docker iptables setting | Outgoing access to internet |
---|---|---|
docker run --rm -it alpine apk add curl |
Default | Yes |
docker run --rm -it alpine apk add curl |
false |
No? (test again to confirm) |
docker run --network=host --rm -it alpine apk add curl |
false |