@@ -32,17 +32,22 @@ following custom `iptables` chains:
3232
3333* ` DOCKER-USER `
3434 * A placeholder for user-defined rules that will be processed before rules
35- in the ` DOCKER ` chain.
35+ in the ` DOCKER-FORWARD ` and ` DOCKER ` chains.
36+ * ` DOCKER-FORWARD `
37+ * The first stage of processing for Docker's networks. Rules that pass packets
38+ that are not related to established connections to the other Docker chains,
39+ as well as rules to accept packets that are part of established connections.
3640* ` DOCKER `
3741 * Rules that determine whether a packet that is not part of an established
3842 connection should be accepted, based on the port forwarding configuration
3943 of running containers.
4044* ` DOCKER-ISOLATION-STAGE-1 ` and ` DOCKER-ISOLATION-STAGE-2 `
4145 * Rules to isolate Docker networks from each other.
46+ * ` DOCKER-INGRESS `
47+ * Rules related to Swarm networking.
4248
43- In the ` FORWARD ` chain, Docker adds rules that pass packets that are not related
44- to established connections to these custom chains, as well as rules to accept
45- packets that are part of established connections.
49+ In the ` FORWARD ` chain, Docker adds rules that unconditionally jump to the
50+ ` DOCKER-USER ` , ` DOCKER-FORWARD ` and ` DOCKER-INGRESS ` chains.
4651
4752In the ` nat ` table, Docker creates chain ` DOCKER ` and adds rules to implement
4853masquerading and port-mapping.
@@ -53,6 +58,8 @@ Packets that get accepted or rejected by rules in these custom chains will not
5358be seen by user-defined rules appended to the ` FORWARD ` chain. So, to add
5459additional rules to filter these packets, use the ` DOCKER-USER ` chain.
5560
61+ Rules appended to the ` FORWARD ` chain will be processed after Docker's rules.
62+
5663### Match the original IP and ports for requests
5764
5865When packets arrive to the ` DOCKER-USER ` chain, they have already passed through
@@ -261,9 +268,9 @@ configure the daemon to use the loopback address (`127.0.0.1`) instead.
261268
262269> [ !WARNING]
263270>
264- > Hosts within the same L2 segment (for example, hosts connected to the same
265- > network switch) can reach ports published to localhost.
266- > For more information, see
271+ > In releases older than 28.0.0, hosts within the same L2 segment (for example,
272+ > hosts connected to the same network switch) can reach ports published to
273+ > localhost. For more information, see
267274> [ moby/moby #45610 ] ( https://github.com/moby/moby/issues/45610 )
268275
269276To configure this setting for user-defined bridge networks, use
@@ -301,16 +308,36 @@ Alternatively, you can use the `dockerd --ip` flag when starting the daemon.
301308
302309## Docker on a router
303310
304- Docker sets the policy for the ` FORWARD ` chain to ` DROP ` . This will prevent
305- your Docker host from acting as a router.
311+ On Linux, Docker needs "IP Forwarding" enabled on the host. So, it enables
312+ the ` sysctl ` settings ` net.ipv4.ip_forward ` and ` net.ipv6.conf.all.forwarding `
313+ it they are not already enabled when it starts. When it does that, it also
314+ sets the policy of the iptables ` FORWARD ` chain to ` DROP ` .
315+
316+ If Docker sets the policy for the ` FORWARD ` chain to ` DROP ` . This will prevent
317+ your Docker host from acting as a router, it is the recommended setting when
318+ IP Forwarding is enabled.
306319
307- If you want your system to function as a router, you must add explicit
308- ` ACCEPT ` rules to the ` DOCKER-USER ` chain. For example:
320+ To stop Docker from setting the ` FORWARD ` chain's policy to ` DROP ` , include
321+ ` "ip-forward-no-drop": true ` in ` /etc/docker/daemon.json ` , or add option
322+ ` --ip-forward-no-drop ` to the ` dockerd ` command line.
323+
324+ Alternatively, you may add ` ACCEPT ` rules to the ` DOCKER-USER ` chain for the
325+ packets you want to forward. For example:
309326
310327``` console
311328$ iptables -I DOCKER-USER -i src_if -o dst_if -j ACCEPT
312329```
313330
331+ > [ !WARNING]
332+ >
333+ > In releases older than 28.0.0, Docker always set the default policy of the
334+ > IPv6 ` FORWARD ` chain to ` DROP ` . In release 28.0.0 and newer, it will only
335+ > set that policy if it enables IPv6 forwarding itself. This has always been
336+ > the behaviour for IPv4 forwarding.
337+ >
338+ > If IPv6 forwarding is enabled on your host before Docker starts, check your
339+ > host's configuration to make sure it is still secure.
340+
314341## Prevent Docker from manipulating iptables
315342
316343It is possible to set the ` iptables ` or ` ip6tables ` keys to ` false ` in
0 commit comments