Can I run Docker in a Virtual Machine?

后端 未结 4 1463
一向
一向 2021-01-31 15:18

I tried to run Docker on a virtual machine.

Host : MacBook 
VM : Parallels Windows 7

And error occurs:

Is it possible?

相关标签:
4条回答
  • 2021-01-31 15:26

    If you would be using Windows 10 Pro or Enterprise and Hyper-V, then all you must do is to enable nested virtualization. On your host, just run (with your guest off):

    > Set-VMProcessor -VMName <VMName> -ExposeVirtualizationExtensions $true
    

    Now you can start your guest and run Docker Desktop as normal.

    0 讨论(0)
  • 2021-01-31 15:28

    If the VM is a Linux, you can do this without any problem - on Linux, the Docker is essentially a well-worked chroot. Thus, the Linux docker is not virtualization.

    In the case of Windows, it is not so easy. Windows Docker internally uses Hyper-V to emulate the containers. Which means that you can only run, if you can use nested virtualization:

    1. On your host machine runs a Windows VM
    2. Inside your Windows VM, runs a HyperV
    3. HyperV is managed by the docker installed on your virtual Windows.

    I tried qemu/kvm, virtualbox and vmware player. I configured them deeply and strongly, I've hacked them, I did every possible to do. Only the last worked (VMWare).

    There are significant speed costs, but it may be useful for development on Linux, and then trial-test on Windows configurations.

    You will need a lot of ram. At least 16G. 32G is better. A relative useful configuration would be:

    • 32GB physical RAM for the physical host
    • 12GB virtual RAM for the Windows VM running on it
    • 8GB virtual RAM inside the Windows VM for the HyperV Linux host.

    Sometimes it will be a little bit buggy, but only your HyperV will crash out, your virtual Win, or your host machine won't. It is okay for testing a docker container on a Windows machine, what you've developed on a Linux. Don't create mission critical servers on this way. :-)

    0 讨论(0)
  • 2021-01-31 15:38

    Worked perfectly fine. Base OS win 10 pro with VirtualBox Version: 6.1 and vagrant with ubuntu 20.04. Using vagrant box follow docker instructions. With vagrant public network no need for port forwarding all apps were accessible.

    0 讨论(0)
  • 2021-01-31 15:46

    You're using Docker Machine in your Windows VM, which is actually going to create a Linux VM inside the Windows VM on your Mac. You can do that, but you need to enable nested virtualization - which I'm not sure you can do in Parallels 7.

    Instead you can run Docker Machine on the Mac directly and use Parallels to create the Linux VM - which means Docker is running in a Linux VM on your Mac, and you don't need nested virtualization.

    Or preferably use Docker for Mac if your OS supports it, it's the latest product and has much better host integration than Docker Machine.

    0 讨论(0)
提交回复
热议问题