[英]How do I copy a file into a docker-cloud container? (AKA How to copy a file over ssh without using scp)
docker-machine has an scp command, but docker-cloud doesn't seem to have any way to transfer a file from my local machine to the cloud container or vice-versa. docker-machine有一个scp命令,但是docker-cloud似乎没有任何方法可以将文件从本地计算机传输到云容器,反之亦然。
I'm submitting an answer below that I've finally figured out (in hopes that it will help someone), but I'd love to hear better answers if there are any! 我在下面提交一个我终于想出的答案(希望它对某人有帮助),但是如果有任何答案,我希望能听到更好的答案!
(I realize docker-cloud is going away, but perhaps this will be helpful for other cloud platforms as well) (我意识到docker-cloud即将消失,但这也许也会对其他云平台有所帮助)
To transfer a file from your local machine to a docker-cloud instance that is running linux with the tee
command available: 使用
tee
命令将文件从本地计算机传输到运行linux的docker-cloud实例:
docker-cloud container exec id12345 tee filename.ext < file_to_copy.ext > /dev/null
(you'll want to redirect output to /dev/null
as shown unless you want the entire contents of the file to be echoed to the terminal... twice) (除非您希望将文件的全部内容回显到终端...两次,否则您将如图所示将输出重定向到
/dev/null
)
To transfer a file to your local machine, is somewhat easier: 要将文件传输到本地计算机,会稍微容易一些:
docker-cloud container exec id12345 cat file_to_copy.ext > filename.ext
Note: I'm not sure this works for binary files, and it can even cause issues with linefeed characters in text files, based on terminal settings, etc. - but it's the best answer I've got short of using an external service like https://transfer.sh 注意:我不确定这是否适用于二进制文件,甚至可能会导致文本文件中的换行符出现问题(基于终端设置等)-但这是最好的答案,因为我缺少使用外部服务(例如https://transfer.sh
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.