Vagrant使用Docker Provider通过ssh同步文件失败

6

我在使用Vagrant和Docker时遇到了问题,主要是由于共享文件夹的rsync出现了问题。

WDFM32388067A:vagranttest d022051$ vagrant up
Bringing machine 'default' up with 'docker' provider...
==> default: Docker host is required. One will be created if necessary...
    default: Vagrant will now create or start a local VM to act as the Docker
    default: host. You'll see the output of the `vagrant up` for this VM below.
    default:  
    default: Importing base box 'hashicorp/boot2docker'...
    default: Matching MAC address for NAT networking...
    default: Checking if box 'hashicorp/boot2docker' is up to date...
    default: Setting the name of the VM: docker-host_default_1438155600426_39792
    default: Clearing any previously set network interfaces...
    default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Forwarding ports...
    default: 2375 => 2375 (adapter 1)
    default: 22 => 2222 (adapter 1)
    default: Running 'pre-boot' VM customizations...
    default: Booting VM...
    default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: docker
    default: SSH auth method: password
    default: Warning: Connection timeout. Retrying...
    default: Machine booted and ready!
==> default: Syncing folders to the host VM...
    default: Installing rsync to the VM...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

rsync --help

Stdout from the command:



Stderr from the command:

sh: rsync: not found

    default: The previous process exited with exit code 1.
    default: The previous process exited with exit code 1.

从错误信息中不能清楚地看出是ssh还是rsync出了问题。可能是因为ssh超时了。我尝试了所有可能的ssh选项,但什么都没有起作用。例如,我设置了config.ssh.private_key_path,但错误信息仍然完全相同。有人遇到过类似的问题吗?


请将您的问题移至[su]。这里是离题的。 - Martin Prikryl
1个回答

2

不,rsync已经安装了。我使用的是MacOS。rsync位于/opt/local/bin下,并且已经加入了环境变量。 - Gregor
我还创建了一个到/bin的符号链接。没有改变任何东西。 - Gregor
啊,我的错,看起来在虚拟机上找不到rsync: default: 正在将rsync安装到虚拟机中... 以下SSH命令的退出状态为非零。 Vagrant认为这意味着命令执行失败! - chris.redekop
你如何指定不同的boot2docker镜像?我正在使用docker作为提供者。 - yorch
没事了,我想通了,你需要一个额外的 Vagrantfile,其中包含类似于以下内容的东西:https://github.com/mitchellh/vagrant/blob/master/plugins/providers/docker/hostmachine/Vagrantfile,与你喜欢的镜像。最后,你只需要在主要的 Vagrantfile 中包含这一行:d.vagrant_vagrantfile = "Vagrantfile-boot2docker" - yorch
@gregor,你找到解决方案了吗?我使用相同的Docker镜像也遇到了同样的问题。 - Wissem

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接