swarm 使用 local volume

本节源码,两个文件

docker-compose.yml

  1. version: "3.8"
  2. services:
  3. db:
  4. image: mysql:5.7
  5. environment:
  6. - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_pass
  7. secrets:
  8. - mysql_pass
  9. volumes:
  10. - data:/var/lib/mysql
  11. volumes:
  12. data:
  13. secrets:
  14. mysql_pass:
  15. file: mysql_pass.txt

mysql_pass.txt

  1. vagrant@swarm-manager:~$ more mysql_pass.txt
  2. abc123
  3. vagrant@swarm-manager:~$