pub struct ContainerToContainer {
pub default_policy: ChainPolicy,
pub same_network_verdict: Option<RuleVerdict>,
pub rules: Option<Vec<ContainerToContainerRule>>,
}Expand description
The container-to-container section, defining how containers can communicate amongst each other.
Fields§
§default_policy: ChainPolicyThe default_policy defines the default for when there is not a specific rule.
§Filtering traffic within the same bridge
Depending on how your host is configured, traffic whose origin and destination interface are the same bridge is not filtered by the kernel netfilter module. This means that this default policy is not honored for traffic between containers that are on the same Docker network, but only for traffic that traverses two bridges.
If your kernel has the br_netfilter kernel-module available, you can set the sysctl
net.bridge.bridge-nf-call-iptables to 1 to have the netfilter-module act on traffic
within the same bridge, too. You can set this value temporarily like this:
sysctl net.bridge.bridge-nf-call-iptables=1To permanently set this configuration, take a look at man sysctl.d and man sysctl.conf.
same_network_verdict: Option<RuleVerdict>Configure whether traffic between containers within the same network should be allowed or not.
This option is more specific than default_policy, applying to traffic between containers
on the same network, rather than also applying across networks. This option has precedence
over the default_policy for traffic on the same network.
§Example
Setting the same_network_verdict to accept will allow all traffic between containers on
the same network to pass, regardless of the default_policy configured:
[container_to_container]
default_policy = "drop"
same_network_verdict = "accept"If you want to allow traffic between containers on the same networks in general, but want to restrict traffic on some networks, you can additionally add container-to-container rules to disallow traffic between containers for the desired networks:
[container_to_container]
default_policy = "drop"
same_network_verdict = "accept"
[[container_to_container.rules]]
network = "restricted_network"
verdict = "reject"§Host configuration
Depending on how your host is configured, traffic whose origin and destination interface are the same bridge (network) is not filtered by the kernel netfilter module.
This means that this verdict is only honored if your kernel has the br_netfilter
kernel-module available and the sysctl net.bridge.bridge-nf-call-iptables is set to 1.
Otherwise traffic between containers on the same network will always be allowed.
You can set the sysctl-value temporarily like this:
sysctl net.bridge.bridge-nf-call-iptables=1To permanently set this configuration, take a look at man sysctl.d and man sysctl.conf.
rules: Option<Vec<ContainerToContainerRule>>An optional list of rules, see
ContainerToContainerRule.
§Example
The easiest way to define the rules is using TOMLs arrays of tables:
[container_to_container]
default_policy = "drop"
[[container_to_container.rules]]
# first rule here
[[container_to_container.rules]]
# second rule hereTrait Implementations§
Source§impl Clone for ContainerToContainer
impl Clone for ContainerToContainer
Source§fn clone(&self) -> ContainerToContainer
fn clone(&self) -> ContainerToContainer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ContainerToContainer
impl Debug for ContainerToContainer
Source§impl<'de> Deserialize<'de> for ContainerToContainer
impl<'de> Deserialize<'de> for ContainerToContainer
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ContainerToContainer
Source§impl Hash for ContainerToContainer
impl Hash for ContainerToContainer
Source§impl PartialEq for ContainerToContainer
impl PartialEq for ContainerToContainer
Source§impl Process<Iptables> for ContainerToContainer
impl Process<Iptables> for ContainerToContainer
Source§fn process(
&self,
ctx: &ProcessContext<'_, Iptables>,
) -> Result<Option<Vec<IptablesRule>>>
fn process( &self, ctx: &ProcessContext<'_, Iptables>, ) -> Result<Option<Vec<IptablesRule>>>
ProcessContext, returning zero or more rules
to apply with nft.Source§impl Process<Nftables> for ContainerToContainer
impl Process<Nftables> for ContainerToContainer
Source§fn process(
&self,
ctx: &ProcessContext<'_, Nftables>,
) -> Result<Option<Vec<String>>>
fn process( &self, ctx: &ProcessContext<'_, Nftables>, ) -> Result<Option<Vec<String>>>
ProcessContext, returning zero or more rules
to apply with nft.impl StructuralPartialEq for ContainerToContainer
Auto Trait Implementations§
impl Freeze for ContainerToContainer
impl RefUnwindSafe for ContainerToContainer
impl Send for ContainerToContainer
impl Sync for ContainerToContainer
impl Unpin for ContainerToContainer
impl UnsafeUnpin for ContainerToContainer
impl UnwindSafe for ContainerToContainer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.