[Docker] -- copy files between the container and host

Source: Internet
Author: User
Tags docker ps docker cp

1. From container to host)

Use the docker CP command

  docker cp <containerId>:/file/path/within/container /host/path/target

 

2. From host to iner

  1. Get container name or short container ID:

    Docker PS

  2. Get full container ID

    Docker inspect-F' {. ID} 'SHORT_CONTAINER_ID-or-CONTAINER_NAME

  3. Copy file:

    Sudo CP path-file-host/var/lib/docker/aufs/mnt/full_container_id/path-New-File

Example:

$ Docker PS

Container IDImage Command created status portsNames

D8e703d7e303Solidleon/ssh: Latest/usr/sbin/sshd-dCranky_pare

$ Docker inspect-F' {. ID} 'cranky_pare

Or

$ Docker inspect-F' {. ID} 'd8e703d7e303

Bytes

$ Sudo CP file.txt/var/lib/docker/aufs/mnt/Bytes/Root/file.txt

[Docker] -- copy files between the container and host

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.