Data Management for Docker containers

Source: Internet
Author: User
Tags docker run

<title>Data Management for Docker containers</title> Data management for Docker containers What is a data volume (Volume)?
    • A data volume is a specially crafted directory that bypasses the Federated file System (UFS) and provides access to one or more containers
    • The purpose of the data volume design is to perpetuate the data, which is completely independent of the container's lifetime, so Docker will not delete its mounted data volumes when the container is deleted, nor will there be a similar garbage collection mechanism to process the data volumes referenced by the container
Features of the data volume (Volume)
    • The data volume is initialized when the container starts, and if the image file 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 image file
    • The volume will persist even if the container on which the data volume is mounted has been deleted
Use of data volumes to add data volumes to containers
1.run -v ~/container_data:/data -it ubuntu /bin/bash

~/container_data: Native file directory
/data: File directory in container

Add access rights to a data volume
1.~/datavolume:/data:/bin/bash

:ro: Read-only file permissions

Use Dockerfile to build mirrors that contain data volumes

Dockerfile directive:
VOLUME["/data"]

Data volume container What is a data volume container?

The named container mounts the data volume, and the other container implements the data share by mounting the container, which is called the data volume container.

How to mount a data volume container
1.run--volumes-from [CONTAINER NAME]
Back up and restore data backup methods for data volumes
1.docker run --volumes-from [container$(pwd):/backup ubuntu tar cvf /backup/backup.tar [container data volume]

Data Restore Methods
1.docker run --volumes-from [container$(pwd):/backup ubuntu tar xvf /backup/backup.tar [container data volume]

Data Management for Docker containers

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.