本文共 703 字,大约阅读时间需要 2 分钟。
docker数据拷贝的方式有很多种,下面介绍几种数据拷贝的方式;此处只是介绍几种简易的方式,更多方式可以google下。
docker cp:/file/path/within/container /host/path/target docker cp 8e7e5f4574f4:/root/test.txt ./test.txt
docker cp /host/path/target:/file/path/within/containerdocker cp ./host.txt 8e7e5f4574f4:/root/host.txt
docker run -v /path/to/hostdir:/mnt $container
其余的在宿主机上操作即可
docker run -i ubuntu /bin/bash -c 'cat > /path/to/container/file' < /path/to/host/file/ # 或者docker exec -itbash -c 'cat > /path/to/container/file' < /path/to/host/file/