1-6docker data sharing and persistence

1, the management data between the internal container and Docker, data management in the vessel there are two main Modes:

Data volume (Data Volumes) 
mounted host of Contents (Bind mounts)

2, data volume

A data volume is ⼀ ⼀ for one or more containers of Contents Using specific, it bypasses the UFS, may be provided with a number of Use: the 
data volume can be shared and re Use of modified data volume between the containers will ⻢ ⽣ effect on attention immediately update data volume, the data volume does not affect the mirror straight default ⼀ exist, even if the container is removed

2-1, data volume is created, mount, delete

-V parameter selection or --mount own habits, the difference between a blog fancy, but is recommended for shooting --mount parameters.
# Create 
Docker my_test the Create Volume 

# View 
Docker the Inspect my_test 

# mount 
 Docker RUN -it -d -p 8091: 80 --mount Source = my_test, target = / opt 172.21.0.10:5000/nginx:v1 


# into the container, create file 
Docker Expediting IT 30137e66d2ec the bash Exec 

CD / opt 
mkdir ZJY 
Exit 

# host to see if the sync 
 LL -d / var / lib / Docker / Volumes / my_test / the _data / * 
drwxr XR-2 X-27 On Sep 4096 the root 18 is the root: 14 / var / lib / Docker / volumes / my_test / the _data / ZJY 


# remove the physical volume 
docker volume rm -f my_test
Host Directory # mount 
directly to it the physical volume name, change the path to the server

 

 

 

Guess you like

Origin www.cnblogs.com/zhaojingyu/p/11599628.html