如何将文件从本地 vagrant 复制到本地系统? [英] How to copy file from local vagrant to local system?

查看:264
本文介绍了如何将文件从本地 vagrant 复制到本地系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 local.conf 从本地 vagrant 机器复制到本地系统(我的机器).Vagrant 在同一台机器上运行.我尝试了以下命令.它运行成功,但是当我在系统上搜索 local.conf 文件时,我什么也没得到.

I want to copy local.conf from local vagrant machine to local system(my machine). Vagrant is running on the same machine. I tried the following command. It run successfully, but when I search local.conf file on my system I get nothing.

[vagrant@localhost devstack]$ scp vagrant@192.168.50.4:/home/vagrant/local.conf local.conf 
vagrant@192.168.50.4's password: 
local.conf                                              100% 3857     3.8KB/s   00:00    
[vagrant@localhost devstack]$ 

推荐答案

要将文件从主机复制到虚拟机(反之亦然),您不一定需要特定的协议,例如作用域或 ftp.

To copy files from host to vm (and vice versa) you do not necessarily need specific protocol like scope or ftp.

默认情况下,vagrant 会自动将 /vagrant 目录设为与您的本地文件夹共享的文件夹.所以你可以将任何文件从 vm 复制到 /vagrant 目录中,你会在你的本地文件夹下看到它们,你有 Vagrantfile 和你初始化 vagrant 的地方.

By default vagrant automatically makes a /vagrant directory a shared folder with your local folder. so you can just copy any files from the vm into the /vagrant directory and you will see them under your local folder where you have the Vagrantfile and where you initialized vagrant.

如果您想与虚拟机共享位于本地硬盘驱动器上的其他文件,您可以轻松地从 Vagrantfile 添加共享文件夹

And if you have other files located on your local hard drive that you want to share with your vm, you can easily add a shared folder from the Vagrantfile

  config.vm.synced_folder "/Users/fhenri/myproject", "/project"

将与虚拟机中的 /project 文件夹共享本地文件夹 /Users/fhenri/myproject ,您可以只使用 mvcp 将文件从一个移动/复制到另一个

will shared the local folder /Users/fhenri/myproject with the /project folder from the vm and you can just use mv or cp to move / copy files from one to another

这篇关于如何将文件从本地 vagrant 复制到本地系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆