Docker Learning notes Docker data volume

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.