1.用-v掛載主機資料捲到容器內
[plain]viewplaincopy
dockerrun-v/path/to/hostdir:/mnt$container
在容器內複製
cp/mnt/sourcefile/path/to/destfile
2.直接在主機上複製到容器物理儲存系統
A.獲取容器名稱或者id:
$dockerps
B.獲取整個容器的id
$dockerinspect-f"{{.Id}}"步驟A獲取的名稱或者id
C.在主機上複製檔案:
$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
例子:
CONTAINERIDIMAGECOMMANDCREATEDSTATUSPORTSNAMES
d8e703d7e303solidleon/ssh:latest/usr/sbin/sshd-Dcranky_pare
$dockerinspect-f"{{.Id}}"cranky_pare
or
$dockerinspect-f"{{.Id}}"d8e703d7e303
d8e703d7e3039a6df6d01bd7fb58d1882e592a85059eb16c4b83cf91847f88e5
$sudocpfile.txt/var/lib/docker/aufs/mnt/**d8e703d7e3039a6df6d01bd7fb58d1882e592a85059eb16c4b83cf91847f88e5
3.用輸入輸出符
dockerrun-iubuntu/bin/bash-c"cat>/path/to/container/file"
dockerexec-it
1.用-v掛載主機資料捲到容器內
[plain]viewplaincopy
dockerrun-v/path/to/hostdir:/mnt$container
在容器內複製
cp/mnt/sourcefile/path/to/destfile
2.直接在主機上複製到容器物理儲存系統
A.獲取容器名稱或者id:
[plain]viewplaincopy
$dockerps
B.獲取整個容器的id
[plain]viewplaincopy
$dockerinspect-f"{{.Id}}"步驟A獲取的名稱或者id
C.在主機上複製檔案:
[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
$dockerps
CONTAINERIDIMAGECOMMANDCREATEDSTATUSPORTSNAMES
d8e703d7e303solidleon/ssh:latest/usr/sbin/sshd-Dcranky_pare
$dockerinspect-f"{{.Id}}"cranky_pare
or
$dockerinspect-f"{{.Id}}"d8e703d7e303
d8e703d7e3039a6df6d01bd7fb58d1882e592a85059eb16c4b83cf91847f88e5
$sudocpfile.txt/var/lib/docker/aufs/mnt/**d8e703d7e3039a6df6d01bd7fb58d1882e592a85059eb16c4b83cf91847f88e5
3.用輸入輸出符
[plain]viewplaincopy
dockerrun-iubuntu/bin/bash-c"cat>/path/to/container/file"
或者
[plain]viewplaincopy
dockerexec-it