Skip to content
Blog

Encrypting Overlay Traffic Between Docker Hosts

Enable --opt encrypted on a Docker overlay to IPsec-encrypt cross-host traffic. What is and isn't encrypted, the documented caveats, and how to verify ESP on the wire.

Published on • November 19, 2026

AI Assistant

By default, every packet your containers exchange between hosts crosses the network as cleartext VXLAN — anyone who can sniff the path between your nodes can read it. Swarm encrypts its control plane unconditionally; your application data plane is a different story. Docker gives you exactly one lever for it: --opt encrypted.

What is encrypted, and what isn’t

The distinction worth internalizing is between the two kinds of traffic a swarm generates:

  • Control and management plane — join/leave requests, scheduling, cluster state. Docker’s documentation states this traffic “is always encrypted”, with or without any flags.
  • Application data plane — container-to-container traffic crossing hosts. Not encrypted by default. This is what --opt encrypted covers.
  • The ingress network — also unencrypted by default, and it needs separate treatment (below), because “encryption is a network-level option” and ingress is created before you ever get a chance to pass options.

There’s one more boundary: overlay encryption isn’t supported on Windows at all. Docker’s warning is blunt — Swarm doesn’t report an error when a Windows host joins an encrypted overlay, but Windows containers can’t communicate with Linux containers on that network, and Windows-to-Windows traffic simply isn’t encrypted. Don’t attach Windows containers to encrypted overlays.

One thing the documentation deliberately does not describe is key management: there are no key flags on docker network create, no rotation settings, nothing to configure. You pass the option; the daemon handles the rest. Anything beyond that isn’t documented, so treat it as opaque by design.

Creating an encrypted overlay

$ docker network create \
    --opt encrypted \
    --driver overlay \
    --attachable \
    my-attachable-multi-host-network

That single option “enables IPsec encryption at the level of the Virtual Extensible LAN (VXLAN)” — the container frames are still VXLAN-encapsulated between hosts, but the packets on the wire are wrapped in IPsec. The documented caveats:

  • “This encryption imposes a non-negligible performance penalty, so you should test this option before using it in production.” Not “slight” — non-negligible. Measure it.
  • It’s a property of the network, not of a container or service. You decide at network create time.
  • Linux nodes only, per the Windows warning above.

The ingress gap most people miss

Your user-defined networks get encryption with one flag, but the automatically created ingress network — the one carrying every published port — stays unencrypted until you recreate it. Docker documents the procedure explicitly:

  1. docker network inspect ingress, find the services whose containers connect to it (services that publish ports), and remove them. Removal fails while they’re attached.
  2. Remove the network: docker network rm ingress (you’ll get a warning — make sure all nodes run the same Engine version first).
  3. Recreate it with the --ingress flag plus your options:
$ docker network create \
    --driver overlay \
    --ingress \
    --subnet=10.11.0.0/16 \
    --gateway=10.11.0.2 \
    --opt encrypted=true \
    --opt com.docker.network.driver.mtu=1200 \
    my-ingress
  1. Restart the services you stopped.

Two details from the docs: you can name the network something other than ingress, but only one may exist; and while no ingress network exists, services that don’t publish ports keep running — published-port services are simply not load-balanced during the gap. If you can, do this before creating any services at all.

Seeing it on the wire

The cleanest proof that encryption is active is a packet capture between two nodes:

# before: plain VXLAN, readable
$ sudo tcpdump -ni eth0 udp port 4789 -c 2
10:11:58.402913 IP 10.0.0.11.45678 > 10.0.0.12.4789: VXLAN, flags [I] (0x08), vni 4097
10:11:58.403104 IP 10.0.0.12.4789 > 10.0.0.11.45678: VXLAN, flags [I] (0x08), vni 4097

# after: the VXLAN signature disappears behind IPsec ESP
$ sudo tcpdump -ni eth0 proto esp -c 2
10:12:03.118473 IP 10.0.0.11 > 10.0.0.12: ESP(spi=0x1c4a93f2,seq=0x5,offset=1360,flags=[.]), length 1420
10:12:03.118611 IP 10.0.0.12 > 10.0.0.11: ESP(spi=0x2b77d015,seq=0x5,offset=1360,flags=[.]), length 1420

On an unencrypted overlay you see UDP/4789 VXLAN directly; with --opt encrypted, the same traffic shows up as ESP — IP protocol 50. Practical consequences: if you firewall the data path by protocol, the rules that allowed udp/4789 now need to allow ESP between nodes as well (the control-plane and discovery ports are unchanged). The content of the frames — including which container sent what — is no longer visible to anyone holding a tap on the link.

The throughput and MTU tax

IPsec adds an ESP header and trailer to every packet, and on top of that Docker documents a “non-negligible performance penalty”. Both effects land on the same place: your effective throughput.

The docs don’t publish an “encrypted MTU” formula — what they do show is how to set the overlay’s MTU (--opt com.docker.network.driver.mtu, as in the ingress example above, where the docs use 1200 and 9216 in different examples), plus the instruction to test before production. If you enable encryption and then see small pings succeed while large transfers stall — the classic wrong-MTU signature — the MTU, not the encryption itself, is the first thing to tune. We walk through that diagnosis in Docker Network MTU Problems.

When to enable it (and the alternative)

Turn it on when hosts exchange overlay traffic over a network you don’t control: cross-rack links you can’t audit, shared cloud networks, or compliance rules that require encryption in transit between machines. It protects all container traffic on that network, including protocols that have no TLS of their own.

Leave it off on a trusted, isolated fabric where latency matters and you’ll benchmark it first — and remember it’s simply unavailable if Windows nodes are in the mix.

The application-level alternative: if your services already speak TLS (or mTLS) to each other, confidentiality no longer depends on the overlay at all — you get it at the cost of application configuration instead of IPsec overhead. The trade-off is coverage: network-level encryption protects everything indiscriminately; application-level TLS only protects what was built for it. Many teams run both — IPsec for the underlay between untrusted hops, TLS for service identity — and let the threat model decide how much of each.

The bottom line

Application traffic between swarm hosts is cleartext VXLAN until you pass --opt encrypted, which wraps it in IPsec at the VXLAN level; control-plane traffic is always encrypted regardless. Ingress needs a remove-and-recreate to get covered, Windows hosts aren’t supported at all, and the documented costs — a non-negligible performance penalty plus ESP overhead that interacts with your MTU — are real. Enable it where the path between hosts is untrusted, verify with tcpdump proto esp, measure before production, and pair it with application-level TLS where service identity matters.

Further reading