Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| notes:docker_swarm [2025/03/05 12:23] – [Create a swarm] frater | notes:docker_swarm [2025/11/13 11:44] (Version actuelle) – frater | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ====== Docker Swarm ====== | ====== Docker Swarm ====== | ||
| + | |||
| + | {{tag> | ||
| ===== Install Docker ===== | ===== Install Docker ===== | ||
| + | |||
| [[https:// | [[https:// | ||
| ==== Install using the apt repository ==== | ==== Install using the apt repository ==== | ||
| + | |||
| Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker apt repository. Afterward, you can install and update Docker from the repository. | Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker apt repository. Afterward, you can install and update Docker from the repository. | ||
| ==== Set up Docker' | ==== Set up Docker' | ||
| + | |||
| To setup official' | To setup official' | ||
| Ligne 38: | Ligne 43: | ||
| ===== Create a swarm ===== | ===== Create a swarm ===== | ||
| - | After you complete the tutorial setup steps, you're ready to create a swarm. Make sure the Docker Engine daemon is started on the host machines. | ||
| - | Open a terminal and ssh into the machine where you want to run your manager node. This tutorial | + | After you complete the setup steps, you're ready to create a swarm. Make sure the Docker Engine daemon is started on the host machines. |
| + | |||
| + | Open a terminal and ssh into the machine where you want to run your manager node. This example we uses a machine named '' | ||
| Run the following command to create a new swarm: | Run the following command to create a new swarm: | ||
| Ligne 51: | Ligne 57: | ||
| <cli> | <cli> | ||
| - | root@docker01: | + | root@docker01: |
| Swarm initialized: | Swarm initialized: | ||
| To add a worker to this swarm, run the following command: | To add a worker to this swarm, run the following command: | ||
| - | docker swarm join --token SWMTKN-1-2[snip]wlr 192.168.99.100:2377 | + | docker swarm join --token SWMTKN-1-2[snip]wlr 192.168.80.10:2377 |
| - | To add a manager to this swarm, run ' | + | To add a manager to this swarm, run '' |
| </ | </ | ||
| - | **take | + | <WRAP center round important> |
| + | Take note of the token provided | ||
| + | </ | ||
| + | |||
| + | ==== Adding manager node ==== | ||
| + | |||
| + | |||
| + | To add a manager to this swarm, run '' | ||
| + | |||
| + | ==== Adding worker node ==== | ||
| To add a worker to this swarm, run the following command: | To add a worker to this swarm, run the following command: | ||
| Ligne 68: | Ligne 83: | ||
| root@docker01: | root@docker01: | ||
| --token SWMTKN-1-2[snip]wlr \ | --token SWMTKN-1-2[snip]wlr \ | ||
| - | 192.168.99.100:2377 | + | 192.168.80.10:2377 |
| </ | </ | ||
| - | To add a manager to this swarm, run 'docker | + | The '' |
| - | The --advertise-addr flag configures | + | The output includes |
| - | The output includes the commands to join new nodes to the swarm. Nodes will join as managers or workers depending on the value for the --token flag. | + | ==== Validate |
| - | Run docker info to view the current state of the swarm: | + | Run '' |
| <cli> | <cli> | ||
| - | root@docker01:~# docker info | + | root@docker00:~# docker info |
| + | Client: Docker Engine - Community | ||
| + | | ||
| + | | ||
| + | Debug Mode: false | ||
| + | | ||
| + | buildx: Docker Buildx (Docker Inc.) | ||
| + | Version: | ||
| + | Path: / | ||
| + | compose: Docker Compose (Docker Inc.) | ||
| + | Version: | ||
| + | Path: / | ||
| - | Containers: | + | Server: |
| - | Running: | + | Containers: |
| - | Paused: 0 | + | Running: |
| - | Stopped: | + | Paused: 0 |
| + | Stopped: | ||
| + | | ||
| + | | ||
| + | | ||
| + | Backing Filesystem: extfs | ||
| ...snip... | ...snip... | ||
| Swarm: active | Swarm: active | ||
| - | NodeID: | + | NodeID: |
| Is Manager: true | Is Manager: true | ||
| + | ClusterID: mbwi9gcqsueen8mcanvme3zc8 | ||
| Managers: 1 | Managers: 1 | ||
| - | Nodes: | + | Nodes: |
| ...snip... | ...snip... | ||
| </ | </ | ||
| - | Run the docker node ls command to view information about nodes: | + | Run the '' |
| <cli> | <cli> | ||
| - | root@docker01:~# docker node ls | + | root@docker00:~# docker node ls |
| - | + | ID HOSTNAME | |
| - | ID | + | nh0izhq4pa2plmjdvy00f8um7 |
| - | dxn1zf6l61qsb1josjja83ngz | + | 7m0t8hrymi0jlmy1jpf85tknt |
| + | tebmpkb8og8ko2jfa2zq0z5oc | ||
| </ | </ | ||
| The * next to the node ID indicates that you're currently connected on this node. | The * next to the node ID indicates that you're currently connected on this node. | ||
| - | Docker Engine Swarm mode automatically names the node with the machine host name. The tutorial covers other columns in later steps. | + | Docker Engine Swarm mode automatically names the node with the machine host name. |
| + | <WRAP center round info> | ||
| + | In my labs, I've setup 3 nodes, deb-docker00, | ||
| + | </ | ||