发布网友 发布时间:2022-04-24 06:14
共1个回答
热心网友 时间:2022-04-10 17:23
1.用-v挂载主机数据卷到容器内[plain]viewplaincopydockerrun-v/path/to/hostdir:/mnt$container在容器内拷贝cp/mnt/sourcefile/path/to/destfile2.直接在主机上拷贝到容器物理存储系统A.获取容器名称或者id:[plain]viewplaincopy$dockerpsB.获取整个容器的id[plain]viewplaincopy$dockerinspect-f'{{.Id}}'步骤A获取的名称或者idC.在主机上拷贝文件:[plain]viewplaincopy$sudocppath-file-host/var/lib/docker/aufs/mnt/FULL_CONTAINER_ID/PATH-NEW-FILE或者$sudocppath-file-host/var/lib/docker/devicemapper/mnt/123abc>/rootfs/root例子:[plain]viewplaincopy$dockerpsCONTAINERIDIMAGECOMMANDCREATEDSTATUSPORTSNAMESd8e703d7e303solidleon/ssh:latest/usr/sbin/sshd-Dcranky_pare$dockerinspect-f'{{.Id}}'cranky_pareor$dockerinspect-f'{{.Id}}'d8e703d7e303d8e703d7e3039a6df6d01bd7fb58d1882e592a85059eb16c4b83cf91847f88e5$sudocpfile.txt/var/lib/docker/aufs/mnt/**d8e703d7e3039a6df6d01bd7fb58d1882e592a85059eb16c4b83cf91847f88e53.用输入输出符[plain]viewplaincopydockerrun-iubuntu/bin/bash-c'cat>/path/to/container/file'bash-c'cat>/path/to/container/file'