Test-Drive LinuxKit OS on Oracle VirtualBox running on macOS Sierra

In my last blog post, I showed how to get started with LinuxKit for Google Cloud Platform. LinuxKit is secure, lean and portable Linux Subsystem for the container movement and it is being built for various platforms which Docker runs on, for example – Azure, VMware ESXi, AWS and bare metal system. It went open source just 10 days back and you can see that the project has received over 2300+ stars in just 1 week time. That’s really appreciating figure. If you are completely new to LinuxKit, please refer my last blog post for understanding its basic concept.

linuxsubsystem

 

Screen Shot 2017-05-01 at 2.46.43 PM

 

Under this blog post, I will show you how LinuxKit OS can be run over VirtualBox running on macOS Sierra. Though the entire steps can be automated( this automation script works well for Ubuntu OS and can be tweaked for macOS), I have put it in simpler way.

Pre-requisites:

Ensure that  the following list of software are installed on your macOS machine:

  • go packages  from https://golang.org/dl/
  • make (using Xcode-select –install)
  • docker Version 17.03.1-ce-mac5 (16048) Channel: stable
  • VirtualBox software installed on macOS Sierra
  • git binary, if not installed

 

Once you have installed the above  packages, verify that they are all up and running. Ensure that Docker is up and running. Let us begin by cloning the LinuxKit repository. Open up the terminal and type the below command:

 

Ajeets-MacBook-Air:~ ajeetraina$ sudo git clone https://github.com/linuxkit/linuxkit

Cloning into ‘linuxkit’…

remote: Counting objects: 20097, done.

remote: Compressing objects: 100% (14/14), done.

remote: Total 20097 (delta 1), reused 0 (delta 0), pack-reused 20082

Receiving objects: 100% (20097/20097), 15.76 MiB | 441.00 KiB/s, done.

Resolving deltas: 100% (12066/12066), done.

Ajeets-MacBook-Air:~ ajeetraina$

 

Building the Image:

 

$cd linuxkit

$ sudo make

 

This build up two essential tools for us – moby and linuxkit.  

Next, we need to copy these tools to our PATH as shown below:

 

$ sudo cp bin/* /usr/local/bin

 

Now it’s time to use Moby to build the image:

$ sudo moby build examples/vmware.yml

 

Screen Shot 2017-05-01 at 3.07.17 PM

 

Hence, moby builds up VMware.vmdk file. To push it to VirtualBox, one can think of various option. If you are completely new to VirtualBox, all you can do is import the VMDK file directly as shown below:

Importing  VMDK into VirtualBox software directly:

 

Screen Shot 2017-05-01 at 3.19.12 PM

 

Type your preferable name under VM name(I named it as LinuxKitOS) and select VMware.vmk from your macOS to import it into VirtualBox. Click on “Create”.

Next, you can start the VM by clicking on “Start” button.

 

Screen Shot 2017-05-01 at 3.19.35 PM

It hardly takes few seconds for LinuxKit OS to come up. Once up, you can run runc command to see the list of services up and running.

VirtualBox_LinuxkitOS_01_05_2017_14_06_59

 

The other option is to covert .VMDK into .VDI format and registering the VM using VBoxManage command as shown below:

$VBoxManage clonehd –format VDI vmware.vmdk vmware.vdi

 

Screen Shot 2017-05-01 at 3.37.38 PM

The above command converts VMDK to VDI format which is now ready to be imported into VirtualBox.

Though LinuxKit comes with QEMU tool, if you still want to use qemu-img  (2 step process) to extract only virtual disk and not complete VM, this is a way to do it as shown below:

 $brew install qemu --env=std --use-gcc

Run the below command to convert VMDK to VDI using qemu:

Ajeets-MacBook-Air$ sudo qemu-img convert vmware.vmdk swap.bin -p

Password:

    (100.00/100%)

Ajeets-MacBook-Air:examples ajeetraina$ sudo VBoxManage convertfromraw swap.bin output.vdi –format VDI

Converting from raw image file=”swap.bin” to file=”output.vdi”…

Creating dynamic image with size 1073741824 bytes (1024MB)…

 

Still I would love to see LinuxKit providing the direct way of importing it into VirtualBox , the similar way how it pushes to Google Cloud Platform. LinuxKit for AWS and Azure is under progress. In the future blog post, I will try to cover how LinuxKit works on other platform like Azure and AWS.

Did you find this blog helpful? Are you planning to explore LinuxKit? Feel free to share your experience. Get in touch @ajeetsraina

If you are looking out for contribution, join me at Docker Community Slack Channel.