1. 从容器内拷贝文件到主机上
docker cp <containerId>:/file/path/within/container /host/path/target
或者
docker cp <containerName>:/file/path/within/container /host/path/target
2. 从主机上拷贝文件到容器内
docker cp /host/path/target <containerId>:/file/path/within/container
或者
docker cp /host/path/target <containerName>:/file/path/within/container
3. docker run -v
-v:表示需要将本地哪个目录挂载到容器中,格式-v<宿主机目录>:<容器目录>
假设我们的所有安装程序都放在了宿主机的/root/software/目录下,现在需要将其挂载到容器的/mnt/software/目录下。
docker cp <containerId>:/file/path/within/container /host/path/target
或者
docker cp <containerName>:/file/path/within/container /host/path/target
2. 从主机上拷贝文件到容器内
docker cp /host/path/target <containerId>:/file/path/within/container
或者
docker cp /host/path/target <containerName>:/file/path/within/container
3. docker run -v
-v:表示需要将本地哪个目录挂载到容器中,格式-v<宿主机目录>:<容器目录>
假设我们的所有安装程序都放在了宿主机的/root/software/目录下,现在需要将其挂载到容器的/mnt/software/目录下。