Creating custom iptables rules

In the previous recipe, we covered how Docker handles iptables rules for the most common container networking needs. However, there may be cases where you wish to extend the default iptables configuration to either allow more access or limit the scope of connectivity. In this recipe, we'll walk through a couple of examples of how to implement custom iptables rules. We'll focus on limiting the scope of sources connecting to services running on your containers as well as allowing the Docker host itself to connect to those services.

Note

The examples provided later are designed to demonstrate the options you have to configure iptables rulesets. The way they are implemented in these examples may or may not make sense in ...

Get Docker Networking Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.