Compose
Reprendre l’exercice HPROXY avec docker compose
$ vi docker-compose.ymlservices: myhaproxy: image: haproxy:1.7 volumes: - "/home/sadmin/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg" ports: - "80:80" depends_on: - web1 - web2 networks: - web web1: image: nginx:1.19-alpine container_name: web1 volumes: - "/home/sadmin/web1:/usr/share/nginx/html" networks: - web web2: image: nginx:1.19-alpine container_name: web2 volumes: - "/home/sadmin/web2:/usr/share/nginx/html" networks: - webnetworks: web:Lancer le compose
$ docker compose up -dReprendre l’exercice producteur/consommateur
$ vi docker-compose.ymlservices:
producteur: image: alpine:3.17 command: ["/bin/sh","-c","while true; do echo `date` : `hostname` >> /mnt/index.html ; sleep 30; done"] volumes: - "nfs_web:/mnt" consommateur: image: nginx:1.19-alpine volumes: - "nfs_web:/usr/share/nginx/html" ports: - "80:80"volumes: nfs_web: driver_opts: type: "nfs" o: "addr=192.168.98.1" device: ":/home/shares/user11"Lancer le compose
$ docker compose up -d