Docker容器与本地进行文件传输
- 在本地终端输入:
docker ps -a
得到:
(base) xxx@DESKTOP-5339HUA:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9f0360b21b28 alkhemi/pytorch0.4.1-cuda9.0-ubuntu16.04:devel "/bin/bash" About a minute ago Up About a minute modest_feynman
- 用得到的镜像名字or编号,在本地终端输入
# 两种选择
docker inspect -f '{{.Id}}' modest_feynman
docker inspect -f '{{.Id}}' 9f0360b21b28
得到:
9f0360b21b281b8d9325a73d3a3a1edf5dd9d79601e6cd92b394ee8bab1a6cad
- 进行文件传输
# 从本地到终端
比如:
docker cp home/test 9f0360b21b281b8d9325a73d3a3a1edf5dd9d79601e6cd92b394ee8bab1a6cad:/home/test
# 从终端到本地
docker cp 9f0360b21b281b8d9325a73d3a3a1edf5dd9d79601e6cd92b394ee8bab1a6cad:/home/test home/test
WELL DONE!