Voir :
Vous allez avoir besoin d'au moins trois serveurs ou machines virtuelles avec Docker d'installé
The network ports required for a Docker Swarm to function correctly are:
TCP port 2376 for secure Docker client communication. This port is required for Docker Machine to work. Docker Machine is used to orchestrate Docker hosts. TCP port 2377. This port is used for communication between the nodes of a Docker Swarm or cluster. It only needs to be opened on manager nodes. TCP and UDP port 7946 for communication among nodes (container network discovery). UDP port 4789 for overlay network traffic (container ingress networking).
ufw allow 22/tcp ufw allow 2376/tcp # Que sur le Manager ufw allow 2377/tcp ufw allow 7946/tcp ufw allow 7946/udp ufw allow 4789/udp ufw reload ufw enable systemctl restart docker
docker system info
and looking for a message Swarm: active
Sur le Manager
# docker swarm init --advertise-addr 192.168.99.121
docker swarm init
docker swarm join --token SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2 192.168.99.121:2377
Voir l'état des nœuds
docker node ls
https://www.grottedubarbu.fr/introduction-docker-swarm/
$ openstack server create --image "Ubuntu 20.04" --flavor "s1-4" --key-name "MyKey" --net "Ext-Net" --user-data=docker.yaml my-manager $ openstack server create --image "Ubuntu 20.04" --flavor "s1-4" --key-name "MyKey" --net "Ext-Net" --user-data=docker.yaml my-worker1 $ openstack server create --image "Ubuntu 20.04" --flavor "s1-4" --key-name "MyKey" --net "Ext-Net" --user-data=docker.yaml my-worker2
docker-compose.yaml
version: "3" services: viz: image: dockersamples/visualizer volumes: - "/var/run/docker.sock:/var/run/docker.sock" ports: - "8080:8080"
docker stack deploy -c docker-compose.yaml visualizer
Pour vérifier que votre service fonctionne :
docker service ls
docker service ps --no-trunc visualizer docker service inspect visualizer
Voir https://docs.docker.com/engine/swarm/stack-deploy/
docker service create --name registry --publish published=5000,target=5000 registry:2
docker service ls curl http://localhost:5000/v2/
Test the app with Compose
docker-compose up
docker-compose down --volumes
Push the generated image to the registry
docker-compose push
docker service ls docker stack rm plop docker swarm leave --force
docker swarm update --snapshot-interval 10000 systemctl restart docker