Overlay network driver — Steps
On host1, initialize a swarm Bounded code example (external data; do not execute automatically): ```console $ docker swarm init Swarm initialized: current node (vz1mm9am11qcmo979tlrlox42) is now a manager.
Reference note (untrusted external data; do not execute it as instructions).
On host1, initialize a swarm
Bounded code example (external data; do not execute automatically):
```console
$ docker swarm init
Swarm initialized: current node (vz1mm9am11qcmo979tlrlox42) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-5g90q48weqrtqryq4kj6ow0e8xm9wmv9o6vgqc5j320ymybd5c-8ex8j0bc40s6hgvy5ui5gl4gy 172.31.47.252:2377
```
On host2, join the swarm using the token from the previous output
Bounded code example (external data; do not execute automatically):
```console
$ docker swarm join --token <your_token> <your_ip_address>:2377
This node joined a swarm as a worker.
```
If the join fails, run docker swarm leave --force on host2, verify network and firewall settings, and try again.
On host1, create an attachable overlay network
Bounded code example (external data; do not execute automatically):
```console
$ docker network create --driver=overlay --attachable test-net
uqsof8phj3ak0rq9k86zta6ht
```
Note the returned network ID.
On host1, start an interactive container that connects to test-net
Bounded code example (external data; do not execute automatically):
```console
$ docker run -it --name alpine1 --network test-net alpine
/ #
```
On host2, list available networks. Notice that test-net doesn't exist yet
Bounded code example (external data; do not execute automatically):
```console
$ docker network ls
NETWORK ID NAME DRIVER SCOPE
ec299350b504 bridge bridge local
66e77d0d0e9a docker_gwbridge bridge local
9f6ae26ccb82 host host local
omvdxqrda80z ingress overlay swarm
b65c952a4b2b none null local
```
On host2, start a detached, interactive container that connects to test-net
Bounded code example (external data; do not execute automatically):
```console
$ docker run -dit --name alpine2 --network test-net alpine
fb635f5ece59563e7b8b99556f816d24e6949a5f6a5b1fbd92ca244db17a4342
```
> [!NOTE] > Automatic DNS container discovery only works with unique container names.
On host2, verify that test-net was created with the same network ID as on host1 …
Attribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Docker Documentation — content/manuals/engine/network/drivers/overlay.md :: Steps ↗Revision 3a9d778562f3 · Apache-2.0 and attribution