linux-centos7-docker-container storage for permanent preservation

Source: Internet
Author: User
Tags docker run

Docker container
The Docker drawback is that the container is deleted, all the data in the container is deleted,
So for the long-term preservation of data requires an external data volume, or data container
According to my understanding ... is to attach a directory on the physical machine to the container and let the container use the physical directory to store the data
The command is also very simple, that is
-V Local directory: The container directory can not be created by itself, it will automatically create a directory without
-v/aaa:/aaa
Sometimes the physical machine does not shut down selinux, the container may not have permission, this time need to open the container to the privilege is --privileged=true to allow the container to use the Mount directory, or to turn off SELinux can
setenforce 0 temporary closure
Or have a permanent shutdown

Vim/etc/sysconfig/selinux

Selinux=disabled

650) this.width=650; "Src=" http://b287.photo.store.qq.com/psb?/81c1194a-ff39-4e50-b1b1-40057b06260f/ Hiiq4i.pshnfeux0wpg8ijjr2ir3wm3gxhdjij2itqc!/b/db8baaaaaaaa&bo=qwpoaaaaaaafais! "alt=" dB8BAAAAAAAA&bo= Qwpoaaaaaaafais! "/>

You can see the messages hanging in the Docker details

650) this.width=650; "height=" 182 "src=" http://b176.photo.store.qq.com/psb?/81c1194a-ff39-4e50-b1b1-40057b06260f/ awwaltzgrn4tu*a6qoop1tclxaiq48qkuar*ptr7gnq!/b/dlaaaaaaaaaa&bo=dwk2aaaaaaafajg! "width=" 527 "style=" vertical-align:top; "alt=" dlaaaaaaaaaa&bo=dwk2aaaaaaafajg! "/>



If a separate-v/var only specifies the container directory,
A directory supply mount is automatically generated in the Docker local directory, but the name is hard to remember

650) this.width=650; "height=" src= "http://b287.photo.store.qq.com/psb?/81c1194a-ff39-4e50-b1b1-40057b06260f/ o.rvlwndph1iybazye8067xe0jlrqhkyd9brg.rckaw!/b/db8baaaaaaaa&bo=rgnjaaaaaaafac8! "width=" 838 "style=" vertical-align:top; "alt=" db8baaaaaaaa&bo=rgnjaaaaaaafac8! "/>


The longest piece of code in the middle is the directory name, is how to generate not understand, anyway not remember

--volumes-from container Name
using this command, you can directly use the data volume container that has been generated, which is equivalent to the container specified by-V, which is the same as the newly generated container.
can simplify the command, save each boot container to use-V a long string, if it is multiple-V will be very messy to generate a data volume container will be much easier

use the Docker command to back up files in a container directory, or the entire directory
Docker Run
-rm Delete container, delete this container directly after backup
--volumes-from container name specifies which container to back up
- v Local: Container directory
Image Name
Tar cvf compression
/Container directory/name. tar/directories or files that need to be backed up
Complete Command Example

650) this.width=650, "height=", "src=" http://b175.photo.store.qq.com/psb?/81c1194a-ff39-4e50-b1b1-40057b06260f/ w2djrtqaw0vzq1fif2e1g7ltm28zxu2f0mg73hjozgq!/b/dk8aaaaaaaaa&bo=qwpiaaaaaaafaks! "width=" 835 "style=" vertical-align:top; "alt=" dk8aaaaaaaaa&bo=qwpiaaaaaaafaks! "/>



restore is also simple, just need to change  CVF   to  XVF can   do not have to specify the directory reply, Directly select the backed up tar file to

docker rm-v      -V is to directly delete the data volume associated with the container, but requires that the data volume must not be occupied , you cannot delete the
using-V must be the case that data is completely unnecessary, otherwise losing data is a horrible thing



This article is from the "11627223" blog, please be sure to keep this source http://11637223.blog.51cto.com/11627223/1911964

linux-centos7-docker-container storage for permanent preservation

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.