Guest User

Untitled

a guest
Aug 2nd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #
  2. # example1-volume.yaml
  3. #
  4.  
  5. - hosts: localhost
  6. tasks:
  7. - name: check if myvolume exists
  8. command: docker volume inspect myvolume
  9. register: myvolume_exists
  10. failed_when: false
  11.  
  12. - name: create myvolume
  13. command: docker volume create --name myvolume
  14. when: myvolume_exists|failed
  15.  
  16. #
  17. # example2-A-Create-volume.yaml
  18. #
  19. - name: Run mariadb
  20. docker_container:
  21. name: mariadb-container
  22. image: mariadb
  23. env:
  24. MYSQL_ROOT_PASSWORD: "secret-password"
  25. MYSQL_DATABASE: "db"
  26. MYSQL_USER: "user"
  27. MYSQL_PASSWORD: "password"
  28. ports:
  29. - "3306:3306"
  30. volumes:
  31. #mariadb-data is a named volume which was automatically created by docker:
  32. - mariadb-data:/var/lib/mysql
  33.  
  34. #
  35. # example2-B-Inspect-volume.sh
  36. sudo docker volume inspect mariadb-data
  37. # You will see below
  38. [
  39. {
  40. "Name": "mariadb-data",
  41. "Driver": "local",
  42. "Mountpoint": "/var/lib/docker/volumes/mariadb-data/_data",
  43. "Labels": null,
  44. "Scope": "local"
  45. }
  46. ]
Add Comment
Please, Sign In to add comment