简体   繁体   English

Windows上的同居Docker和VirtualBox

[英]Cohabitation Docker & VirtualBox on Windows

Docker uses the Hyper V functionality so it has to be enabled for Docker to work properly. Docker使用Hyper V功能,因此必须启用它才能使Docker正常工作。 However, the Hyper V functionality has to be disabled for VirtualBox to work properly (it's possible to create guests and emulate them but only if they're 32bits machines it seems). 但是,必须禁用Hyper V功能,VirtualBox才能正常工作(可以创建来宾并对其进行仿真,但前提是它们只能是32位计算机)。

Is there any way to have an healthy cohabitation with the two and for them to work at the same time? 有什么办法可以使他们与两个人健康共处,并使其同时工作? Instead of enable/disabling the Hyper V option and reboot every time? 而不是启用/禁用Hyper V选项并每次都重新启动?

I understand your pain-point, but AFAIK this is just not possible to attain because of the simple fact that the virtualization technologies you mentioned here are of different types. 我了解您的痛点,但AFAIK不可能实现,因为您在此提到的虚拟化技术属于不同类型这一事实很简单。

Hyper-V is a "Type 1" hyper-visor which runs on host machine hardware. Hyper-V是在主机硬件上运行的“类型1”管理程序。 Other examples in this category include Citrix XenServer and VmWare ESXi. 此类别中的其他示例包括Citrix XenServer和VmWare ESXi。 Virtual Box is a "Type 2" hosted hyper-visor which runs within an OS. Virtual Box是在操作系统内运行的“ Type 2”托管虚拟机监控程序。 Other examples in this category include VmWare Player. 此类别中的其他示例包括VmWare Player。

If you need to toggle b/w these, a restart is eminent. 如果您需要在黑白之间切换,那么重启就迫在眉睫。

A quick way to see the mode is by running "bcdedit" from Command Prompt to see the current config. 快速查看此模式的方法是从命令提示符运行“ bcdedit”以查看当前配置。

  1. To disable Hyper-V run: 要禁用Hyper-V运行:

bcdedit /set hypervisorlaunchtype off bcdedit / set hypervisorlaunchtype关闭

  1. To turn Hyper-V back on run: 若要重新运行Hyper-V:

bcdedit /set hypervisorlaunchtype auto bcdedit / set hypervisorlaunchtype自动

However, you would need to reboot in both the cases. 但是,在两种情况下都需要重新启动。 I just mentioned a easy config way to make you understand what was happening in the boot loader when toggling between the Type 1 and Type 2 hyper-visor modes. 我刚刚提到了一种简单的配置方法,可让您了解在类型1和类型2虚拟机管理程序模式之间切换时引导加载程序中发生的情况。

You can't have Hyper-V and VirtualBox together. 您不能将Hyper-V和VirtualBox一起使用。 But you can use the older docker toolbox if you wish. 但是,您可以根据需要使用较旧的docker工具箱 Unlike Docker for Window, Docker Toolbox uses VirtualBox and then you won't need Hyper-V. 与适用于Window的Docker不同,Docker Toolbox使用VirtualBox,因此您不需要Hyper-V。

No there isn't. 不,没有。

Just do as I did and create those VMs in Hyper-V. 像我一样做,并在Hyper-V中创建这些VM。 Hyper-V is super fast and the only problem is graphics. Hyper-V超级快,唯一的问题是图形。 Well nat also, and shared folders. 也不错,和共享文件夹。

I installed a Xserver for Windows (xming) and sent the display from the VM to the desktop and works perfectly. 我安装了用于Windows(xming)的Xserver,并将显示从VM发送到桌面,并且运行良好。

  1. Download and install xserver in windows from here: https://sourceforge.net/projects/vcxsrv/ 从此处下载并在Windows中安装xserver: https//sourceforge.net/projects/vcxsrv/
  2. Install your distribution in a new Hyper-V virtual machine. 在新的Hyper-V虚拟机中安装发行版。 Look in internet for instructions. 在互联网上查找说明。
  3. Run your virtual machine and open a command prompt outside the GUI: Ctrl+Alt+F2. 运行虚拟机,然后在GUI外部打开命令提示符:Ctrl + Alt + F2。 Type the following commands: 键入以下命令:

sudo apt install xfce4 echo xfce4-session >~/.xsession env DISPLAY=yourwindowsip:0.0 LIBGL_ALWAYS_INDIRECT=1 startxfce4

It should start a xfce desktop in windows. 它应该在Windows中启动xfce桌面。 You can reduce the panels, and also hide the desktop window. 您可以缩小面板,也可以隐藏桌面窗口。 It works very well and well integrated with windows desktop 它工作得很好,并与Windows桌面很好地集成在一起

UPDATE Check that your virtual machine and your host won't get the same IP. 更新检查您的虚拟机和主机不会获得相同的IP。 If it happens put an static IP in your virtual machine. 如果发生这种情况,请在您的虚拟机中放置一个静态IP。

If you install the beta channel of Docker for Windows , it will provision a Hyper-V VM running Linux for you, which co-exists with Docker running natively on Windows. 如果您安装Docker for Windows的beta通道,它将为您提供一个运行Linux的Hyper-V VM,该VM与在Windows上本地运行的Docker共存。

Then you can easily switch between Windows and Linux Docker Engines on the same Windows box. 然后,您可以在同一Windows框中轻松地在Windows和Linux Docker引擎之间切换

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM