热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

流氓:同步文件夹与boot2docker框在Windows上-Vagrant:Syncfolderwithboot2dockerboxonWindows

Itrytosynchronizeafolderwiththeboot2dockerVagrantbox(onWindows8.1):我尝试将文件夹与boot2docker

I try to synchronize a folder with the boot2docker Vagrant box (on Windows 8.1):

我尝试将文件夹与boot2docker流浪箱(在Windows 8.1上)同步:

Vagrantfile

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.hostname = "docker-host"
  config.vm.box = "hashicorp/boot2docker"
  config.vm.synced_folder "./src", "/sync/src"
end

I tried several ways to synchronize the folder:

我尝试了几种方法来同步文件夹:

If I do not define a type (how to sync), Vagrant uses SMB. So it's like I have written:

如果我不定义类型(如何同步),则Vagrant使用SMB。就像我写的:

config.vm.synced_folder "./src", "/sync/src", type: "smb"

With this configuration mounting fails (I enter the credentials of my Windows account I'm logged in):

这个配置安装失败(我输入我登录的Windows帐户的凭据):

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/boot2docker' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Preparing SMB shared folders...
    default: You will be asked for the username and password to use for the SMB
    default: folders shortly. Please use the proper username/password of your
    default: Windows account.
    default:
    default: Username: My Username
    default: Password (will be hidden):
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 2375 (guest) => 2375 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (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: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
GuestAdditions versions on your host (5.0.20) and guest (4.3.28 r100309) do not match.
The guest's platform ("tinycore") is currently not supported, will try generic Linux method...
Copy iso file C:\Program Files/Oracle/VirtualBox/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Installing Virtualbox Guest Additions 5.0.20 - guest version is 4.3.28 r100309
mkdir: can't create directory '/tmp/selfgz99220132': No such file or directory
Cannot create target directory /tmp/selfgz99220132
You should try option --target OtherDirectory
An error occurred during installation of VirtualBox Guest Additions 5.0.20. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
==> default: Setting hostname...
==> default: Mounting SMB shared folders...
    default: C:/my-project/src => /sync/src
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t cifs -o uid=`id -u docker`,gid=`getent group docker | cut -d: -f3`,sec=ntlm,credentials=/etc/smb_creds_d1d75b0a1810a196107486250f8d20f4 //169.254.152.12/d1d75b0a1810a196107486250f8d20f4 /sync/src
mount -t cifs -o uid=`id -u docker`,gid=`id -g docker`,sec=ntlm,credentials=/etc/smb_creds_d1d75b0a1810a196107486250f8d20f4 //169.254.152.12/d1d75b0a1810a196107486250f8d20f4 /sync/src

The error output from the last command was:

mount: mounting //169.254.152.12/d1d75b0a1810a196107486250f8d20f4 on /sync/src failed: Invalid argument

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

If I use

如果我使用

config.vm.synced_folder "./src", "/sync/src", type: "nfs"

instead, Vagrant still uses SMB (same output as before). If I use

相反,Vagrant仍然使用SMB(与前面相同的输出)。如果我使用

config.vm.synced_folder "./src", "/sync/src", type: "virtualbox"

I get

我得到

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/boot2docker' is up to date...
==> default: Clearing any previously set forwarded ports...
The synced folder type 'virtualbox' is reporting as unusable for
your current setup. Please verify you have all the proper
prerequisites for using this shared folder type and try again.

If I use

如果我使用

config.vm.synced_folder "./src", "/sync/src", type: "rsync"

with vagrant-gatling-rsync plugin installed

与vagrant-gatling-rsync插件安装

vagrant plugin install vagrant-gatling-rsync

and run in Cygwin (Cmd has no rsync), I get this:

在Cygwin中运行(Cmd没有rsync),我得到:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/boot2docker' is up to date...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 2375 (guest) => 2375 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (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: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
GuestAdditions versions on your host (5.0.20) and guest (4.3.28 r100309) do not match.
The guest's platform ("tinycore") is currently not supported, will try generic Linux method...
Copy iso file C:\Program Files/Oracle/VirtualBox/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Installing Virtualbox Guest Additions 5.0.20 - guest version is 4.3.28 r100309
mkdir: can't create directory '/tmp/selfgz95812741': No such file or directory
Cannot create target directory /tmp/selfgz95812741
You should try option --target OtherDirectory
An error occurred during installation of VirtualBox Guest Additions 5.0.20. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
==> default: Setting hostname...
==> default: Installing rsync to the VM...
==> default: The machine you're rsyncing folders to is configured to use
==> default: password-based authentication. Vagrant can't script rsync to automatically
==> default: enter this password, so you'll likely be prompted for a password
==> default: shortly.
==> default:
==> default: If you don't want to have to do this, please enable automatic
==> default: key insertion using `config.ssh.insert_key`.
==> default: Rsyncing folder: /cygdrive/c/my-project/src/ => /sync/src
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.

Host path: /cygdrive/c/my-project/src/
Guest path: /sync/src
Command: rsync --verbose --archive --delete -z --copy-links --chmod=ugo=rwX --no-perms --no-owner --no-group --rsync-path sudo rsync -e ssh -p 2222 -o COntrolMaster=auto -o COntrolPath=C:/cygwin64/tmp/ssh.640 -o COntrolPersist=10m -o StrictHostKeyChecking=no -o IdentitiesOnly=true -o UserKnownHostsFile=/dev/null --exclude .vagrant/ /cygdrive/c/my-project/src/ docker@127.0.0.1:/sync/src
Error: Warning: Permanently added '[127.0.0.1]:2222' (ECDSA) to the list of known hosts.
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password,keyboard-interactive).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.1]

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

Besides that, I tried another boot2docker box

除此之外,我还尝试了另一个boot2docker盒子

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.hostname = "docker-host"
  config.vm.box = "dduportal/boot2docker"
  config.vm.synced_folder "./src", "/sync/src"
end

which results in

这将导致

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'dduportal/boot2docker' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostOnly==> default: Forwarding ports...
    default: 2375 (guest) => 2375 (host) (adapter 1)
    default: 2376 (guest) => 2376 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> 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: private key
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...


==> default: Waiting for cleanup before exiting...
Vagrant exited after cleanup due to external interrupt.

How do I get folder synchonization to run with Vagrant and boot2docker?

我如何让文件夹同步运行与流浪和boot2docker?

1 个解决方案

#1


0  

My working setup with dduportal/boot2docker on windows looks like the following:

我在windows上使用dduportal/boot2docker的工作设置如下:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.hostname = "docker-host"
  config.vm.box = "dduportal/boot2docker"
  config.vm.provision "docker"
  config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
end

推荐阅读
  • 在Win10上安装Centos7
    博主之前是用VMWare安装Centos机器的但是后来发现,还是比较麻烦的.需要各种配置比较繁琐,后来接触了VargrantVirtualBox后发现安装Centos,如此简单1. ... [详细]
  • Linux中使用Shell脚本获取网络配置信息
    本文提供了一组Shell命令,用于在Linux系统中提取IP地址、子网掩码、MAC地址及默认网关等关键网络配置信息。 ... [详细]
  • 本文探讨了Web API 2中特性的路由机制,特别是如何利用它来构建RESTful风格的URI。文章不仅介绍了基本的特性路由使用方法,还详细说明了如何通过特性路由进行API版本控制、HTTP方法的指定、路由前缀的应用以及路由约束的设置。 ... [详细]
  • 本文探讨了 Boost 库中的 Program Options 组件,这是一个强大的工具,用于解析命令行参数和配置文件。文章介绍了如何正确设置和使用该组件,包括处理复杂选项和负数值的方法。 ... [详细]
  • Python闭包深度解析与应用实例
    本文详细介绍了Python闭包的基本概念、必要条件及其实现方式,并通过具体示例说明闭包在提高代码复用性和维护性方面的作用。文章最后还探讨了闭包的内部机制及其在实际项目中的应用。 ... [详细]
  • 探讨了生成时间敏感的一次性伪随机密码的方法,旨在通过加入时间因素防止重放攻击。 ... [详细]
  • GCC(GNU Compiler Collection)是GNU项目下的一款功能全面且高效的多平台编译工具,广泛应用于Linux操作系统中。本文将详细介绍GCC的特点及其基本使用方法。 ... [详细]
  • 如何更换Anaconda和pip的国内镜像源
    本文详细介绍了如何通过国内多个知名镜像站(如北京外国语大学、中国科学技术大学、阿里巴巴等)更换Anaconda和pip的源,以提高软件包的下载速度和安装效率。 ... [详细]
  • 本文详细介绍了如何在 EasyUI 框架中实现 DataGrid 组件的分页功能,包括配置方法和常见问题的解决方案。 ... [详细]
  • 微服务自动化.dockercompose
    目录一、docker-compose二、docker-compose安装与配置1、修改docker.service2、下载文件3、将刚才下载的docker-compose文 ... [详细]
  • 本文详细介绍了Socket在Linux内核中的实现机制,包括基本的Socket结构、协议操作集以及不同协议下的具体实现。通过这些内容,读者可以更好地理解Socket的工作原理。 ... [详细]
  • 浅析python实现布隆过滤器及Redis中的缓存穿透原理_python
    本文带你了解了位图的实现,布隆过滤器的原理及Python中的使用,以及布隆过滤器如何应对Redis中的缓存穿透,相信你对布隆过滤 ... [详细]
  • 本文将详细介绍如何注册码云账号、配置SSH公钥、安装必要的开发工具,并逐步讲解如何下载、编译 HarmonyOS 2.0 源码。通过本文,您将能够顺利完成 HarmonyOS 2.0 的环境搭建和源码编译。 ... [详细]
  • 本文介绍了5个基本Linux命令行工具的现代化替代品,包括du、top和ncdu。这些替代品在功能上进行了改进,提高了可用性,并且适用于现代化系统。其中,ncdu是du的替代品,它提供了与du类似的结果,但在一个基于curses的交互式界面中,重点关注占用磁盘空间较多的目录。 ... [详细]
  • 里加|此功能_Vagrant定制个性化CentOS7模板
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了Vagrant定制个性化CentOS7模板相关的知识,希望对你有一定的参考价值。 ... [详细]
author-avatar
mobiledu2502876597
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有