------of Novice Learning Docker file transfer between container and host

Source: Internet
Author: User
Tags docker cp docker run
Application Scenarios
The project team now changes the release plan to release the package entirely in the form of a Docker mirror. This can be:
• Go to operating system and operation Environment dependence
• Facilitates the continuous integration of software release processes
• Efficiently speed up release and validation

In this way, when the image is released, the file system of the software needs to be added to the mirror, that is, the transmission of the file system is involved. After searching on the internet, we found that there are many ways to achieve this, and now we use the easiest and easiest way to do it.

The host machine's files are transferred to the container
STEP1: First create a new "trans_file.txt" file in the/home/directory in the container dc1c56b06f2f and write the contents of the file:
#This is a test file to show file translation from
#container to its host
#So, here we go ...
STEP2: Create a new terminal and type the command "sudo docker cp dc1c56b06f2f:/home/trans_file.txt/home"
STEP3: View the file on the host machine for replication OK.

The files in the container are transferred to the host machine

STEP1: First create a new "Test0504.txt" file on the host machine and write the contents:
#This is a test file to show example of translation file (s)
#between host and container.
#So, here we are go!
STEP2: Use parameter "-V" to implement file Mount function: "Docker run–i–t-v/home/:/home/ahailun/test:ubuntu15.10.py/bin/bash", this command is to the host machine directory/home/ The table of contents (the part before the colon) is mounted under the/home/(the part after the colon) in the container.
STEP3: You can see, the container in the/home/directory of the file has been successfully mounted, in the container can be in time CP out.



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.