Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I run Docker in a Virtual Machine?

I tried to run Docker on a virtual machine.

Host : MacBook  VM : Parallels Windows 7 

And error occurs:

enter image description here

Is it possible?

like image 329
shkim Avatar asked Sep 27 '16 08:09

shkim


People also ask

Is it OK to run Docker in a VM?

Since it doesn't virtualize components, its host OS needs to have access to the Linux kernel and other Linux components. That means you can only use Docker to run the Linux OS and not Windows or Mac OS. If you need to run Windows or OS X, you're stuck with virtualization.

How do I run a Docker container on a virtual machine?

To run a Docker container, you: create a new (or start an existing) Docker virtual machine. switch your environment to your new VM. use the docker client to create, load, and manage containers.

How do I run a Docker in Windows virtual machine?

To run a Docker container, you: create a new (or start an existing) Docker virtual machine. switch your environment to your new VM. use the docker client to create, load, and manage containers.

Can Docker run on VirtualBox?

Docker machines runs as a VirtualBox virtual machine as you're using the VirtualBox Docker Machine driver. So, it uses up your system memory (RAM). You may not want to run all the Docker machines at the same time. Instead, run only the machines you need.


1 Answers

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. :-)

like image 59
peterh Avatar answered Oct 10 '22 04:10

peterh