## Docker Support

### Tom Eastep

Copyright © 2016 Thomas M. Eastep

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover, and with no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.

2016/12/20

## Shorewall 5.0.5 and Earlier

Both Docker and Shorewall assume that they 'own' the iptables configuration. This leads to problems when Shorewall is restarted or reloaded, because it drops all of the rules added by Docker. Fortunately, the extensibility features in Shorewall allow users to create their own solution for saving the Docker-generated rules before these operations and restoring them afterwards.

## Shorewall 5.0.6 and Later

Beginning with Shorewall 5.0.6, Shorewall has native support for simple Docker configurations. This support is enabled by setting DOCKER=Yes in shorewall.conf. With this setting, the generated script saves the Docker-created ruleset before executing a stop, start, restart or reload operation and restores those rules along with the Shorewall-generated ruleset.

This support assumes that the default Docker bridge (docker0) is being used. It is recommended that this bridge be defined to Shorewall in shorewall-interfaces(8). As shown below, you can control inter-container communication using the `bridge` and `routeback` options. If docker0 is not defined to Shorewall, then Shorewall will save and restore the FORWARD chain rules involving that interface.

`/etc/shorewall/shorewall.conf`:

    DOCKER=Yes

`/etc/shorewall/zones`:

    #ZONE         TYPE        OPTIONS
    dock          ipv4        #'dock' is just an example -- call it anything you like

`/etc/shorewall/policy`:

    #SOURCE        DEST        POLICY         LEVEL
    dock           $FW         REJECT
    dock           all         ACCEPT

`/etc/shorewall/interfaces`:

    #ZONE          INTERFACE        OPTIONS
    dock           docker0          bridge   #Allow ICC (bridge implies routeback=1)

or

    #ZONE          INTERFACE        OPTIONS
    dock           docker0          bridge,routeback=0   #Disallow ICC