Docker data volumes
A data volume is a specially crafted directory that can bypass the federated file System (UFS) and provide access to one or more containers
Features of the data volume:
The data volume is initialized when the container starts, and if the image used by the container contains data at the mount point, the data is copied to the newly initialized data volume
Data volumes can be shared and reused between containers
Can modify the contents of the data volume directly
Changes to the data volume do not affect the update of the mirror
The volume will persist even if the container on which the data volume is mounted has been deleted
To add a data volume to a container:
Docker Run-v ~/container_data:/data-it Centos/bin/bash
: Container_data to local directory
:/data directory for container mount points
Add access rights to a data volume
Docker Run-v ~/container_data:/data:ro-it Centos/bin/bash
Use volume["/home/dockervolume1" in the Dockerfile file, "/home/dockervolume2"]
What is a data volume container:
The named container mounts the data volume, and the other container implements the data sharing by mounting the container, which is called the data volume container.
How to mount a data volume container:
Docker run--volumes-from [CONTAINER NAME]
Backup and restore of Docker data volumes
Data backup method:
Docker run--volumes-from [container name]-V ${pwd}:/backup CentOS
Tar Cvf/backup/backup.tar [container data volume]
Docker run--volumes-from dvt5-v ~/backup:/backup--name dvt10 CentOS tar cvf/backup/dvt5.tar/datavolume1
Docker Learning notes Docker data volume