Original article, welcome to reprint. Reprint please specify: reprint from IT people story, thank you! Docker persistent storage and Data sharing

From this start docker data persistent storage and data sharing.

Remember the difference between image and Container
  • Image cannot write data. Container can write data

Container can write data and perform operations, but data is limited to this container.




Scene problem
  • To delete the container by mistake

If I create a mysql container that has been running for a year and contains a lot of data, the container will lose a year’s worth of data in case of misoperation. This is unacceptable. When data is king, data loss is terrible.

  • Docker introduces the persistence mechanism Data Volume

The program in the figure is stored in two places: 1. Stored in the corresponding layer; 2




image.png

  • Docker persisted data scheme
  1. Volume based on the local file system. When Docker create or Docker run is executed, the host directory can be used as the container’s data volume through the -v parameter, basically in this way.
  2. Volume of plugin supports third-party storage solutions, such as NAS and AWS
  • The type of Volume
  1. The data Volume received and managed is automatically created by the Docker background. The location is fixed and the name is random
  2. The mount location can be specified by users.

PS: source github.com/limingios/d… No.3 Is convenient for learning persistent storage of data