<>Docker Data volume mount

<> one . Data volume mount

* Personal view # stay Docker There are several different ways to mount data volumes in # 1. stay docker run When use -v Host Directory : Container directory
Persistent data volumes are hung locally After deleting the container Local data will not be deleted #2. stay docker run When use --volumes-from Data volume container id
To synchronize data between containers Multiple containers can be bound for data synchronization , Only the container data volume with all data synchronization deleted will disappear #3. You can also docker
build Mount the container data volume when
* Data volume command
Command description
docker run -v Host Directory : Container directory persistent data volume is hung locally More than one # Commonly used
docker run --volumes-from container id Containers synchronize data with each other similar cp The way
<> two . Data volume instance

<>1. docker run -v

* with centos7 Container as an example Create a directory and delete the container to see whether the local data is deleted
* There are no folders and files in the current directory , Next, bind to the container
* You can see we're entering centos Container was created test.txt file , Check whether there is this file after exiting the container
* You can see that the local directory outside the container has this test.txt Documented , It indicates that the data volume has been mounted successfully , We are deleting this container to see if the file will be deleted
* You can see that the file has not been deleted , In this way, the container data will not be deleted by hand, and all the data will be lost , That is to delete the database and run away ~
<>2. docker run --volumes-from

* Also with centos As an example , Open both containers , See whether the two containers will synchronize data
* You can see that the directory has been synchronized , Next, try creating a file
- You can see in centos1 Files created in the container can also be synchronized to centos2 in

©2019-2020 Toolsou All rights reserved,
Solve in servlet The Chinese output in is a question mark C String function and character function in language MySQL management 35 A small coup optimization Java performance —— Concise article Seven sorting algorithms (java code ) use Ansible Batch deployment SSH Password free login to remote host according to excel generate create Build table SQL sentence Spring Source code series ( sixteen )Spring merge BeanDefinition Principle of Virtual machine installation Linux course What are the common exception classes ?