Stack Solution
cat docker-compose.ymlservices: producteur: image: alpine:3.17 command: ["/bin/sh","-c","while true ; do echo `date` : `hostname` >> /mnt/index.html ; sleep 60 ; done"] volumes: - "nfs_web:/mnt" networks: - web deploy: mode: global consommateur: image: nginx:1.19-alpine volumes: - "nfs_web:/usr/share/nginx/html" ports: - "80:80" networks: - web deploy: replicas: 4networks: web:volumes: nfs_web: driver_opts: type: "nfs" o: "addr=192.168.1.5" device: ":/home/shares/user11"Créer la stack
docker stack deploy -c docker-compose.yml mystackSince --detach=false was not specified, tasks will be created in the background.In a future release, --detach=false will become the default.Creating network mystack_webCreating service mystack_producteurCreating service mystack_consommateurLister la stack
docker stack lsNAME SERVICESmystack 2Lister les tasks
docker stack ps mystackID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS0e3mn4uk26mi mystack_consommateur.1 nginx:1.19-alpine host112 Running Running about a minute agoqso698588kms mystack_consommateur.2 nginx:1.19-alpine host113 Running Running about a minute agoqmepd1r8g62e mystack_consommateur.3 nginx:1.19-alpine host112 Running Running about a minute ago6zpdm43cuzjp mystack_consommateur.4 nginx:1.19-alpine host113 Running Running about a minute agonyc3l8tjvhl1 mystack_producteur.lbg3wl9lbwlhfrr4euz2ixgpi alpine:3.17 host112 Running Running about a minute agoc61d9aot51m3 mystack_producteur.sgd84a7jb5iv4ar6m87zn4znh alpine:3.17 host113 Running Running about a minute ago