Six series docker data volume container

docker data volume of the container

A. Data volume container

  When docker container operation, will produce a series of documents, we hope to provide data generated by container to other containers, that is how the sharing of data between the container it? This requires the use of the container volume data we have mentioned.

II. How to achieve data volume container

  Way to achieve data container volume is very simple, first of all we need to create a container, then other containers --volumes-from command to mount the container (parent container). Specific process is as follows:

  a mirror mycentos we created based on a:. me, to start a container, called doc1, the command is: Docker RUN -it --name doc1 mycentos: Me

                                                     

      . b restarting a container, called doc2, inheritance doc1, the command is: Docker RUN -it --name-doc2 --volumes from doc1 mycentos: Me            

                                                     

       . C doc1 at the new / containerDataVolumn / directory file, and add the content as shown below: 

                                                     

     Doc2 into the container / containerDataVolumn / directory, file view, and view the contents, as shown below: 

                                                    

   D. doc2_add.txt add files under / containerDataVolumn directory doc2 container, and then under a directory corresponding doc1 container, will finding is consistent with step c.

  . E then start a new name doc3 container, into the lower doc3 / containerDataVolumn directory, and will see doc1_add.txt doc2_add.txt document, as shown below:

                                                     

   F. Adding doc3_add.txt doc3 file data volume, and can be seen in doc1 doc2 vessel.

  g. The container doc1 delete, or add files in doc2 doc3, the data between them is still visible.

 

Guess you like

Origin www.cnblogs.com/miller-zou/p/11110322.html