- [Instructor] It's important that not just
the Docker daemon is secured,
but also that the entire Docker cluster
is secured as well because you have multiple managers
and workers all communicating together
to form this Docker cluster.
So how does security work in Docker Swarm?
Well, first off, you need to be aware of a term called MTLS,
or mutually authenticated TLS.
This is mutually authenticated transport layer security.
And it's important because
if you had to manually rotate the security certificates
between all of the nodes
that make up the Docker Swarm cluster,
that would be painful.
And doing it without downtime would be even harder.
And that's why MTLS is built into Docker Swarm
and it solves these challenges.
It allows the security certificates between the hosts,
or the nodes, that make up the Docker Swarm cluster
to be automatically rotated
at a set interval
with zero downtime to the applications or the cluster.
So here's how it works.
Built in to Docker Swarm clusters
is a public key infrastructure, or PKI,
that facilitates secure communication
between all the nodes in the cluster.
The nodes use MTLS for authentication, authorization,
and encryption of all communication.
So when you first initialize your Docker Swarm cluster
and the first node that comes online is a manager,
that node has a built-in certificate authority, or CA,
that's created.
From there, as you add new manager nodes,
the key pair initially created
is used for secure communication between future nodes.
The first manager node also creates tokens
to be used for workers or managers to join the cluster.
In those tokens are a digest of the root CA certificate
and a randomly generated secret.
On top of the cluster is a universal control plane, or UCP,
and then from there, you can run your applications
securely and efficiently.
Swarm managers are in constant communication
with each other,
and the worker nodes talk to the managers.
Every three months, each node in the cluster
renews its certificate automatically using MTLS.
Now, I covered this topic
over in my Docker orchestration course with Swarm,
but I wanna briefly review the difference
between Swarm managers
and Swarm workers.
So Swarm managers maintain the cluster state,
they're continually talking with each other
to schedule services,
and they serve as the Swarm HTTP API endpoints.
Workers, on the other hand, are solely dedicated
to executing container workloads.
That's all they do.
So the managers have a much bigger role,
a much more important job,
than, for example, the Swarm workers,
but the managers can also execute workloads
if you would like them to be a worker as well.
However, in large production clusters,
you're going to have a dedicated pool
of nodes that are just managers.
And then the last thing that I wanna talk about
is if you're concerned that a Swarm node
might be compromised in your cluster,
you can easily run docker swarm ca --rotate
on any of the Swarm managers
to immediately generate a new CA certificate and key
that will be automatically distributed
to all of the other managers and workers
in the cluster using MTLS.