Join our Discord Server
Ajeet Raina Ajeet Singh Raina is a former Docker Captain, Community Leader and Arm Ambassador. He is a founder of Collabnix blogging site and has authored more than 570+ blogs on Docker, Kubernetes and Cloud-Native Technology. He runs a community Slack of 8900+ members and discord server close to 2200+ members. You can follow him on Twitter(@ajeetsraina).

Building Docker For Mac 17.06 Community Edition using Moby & LinuxKit

3 min read

Docker For Mac 17.06 CE edition is the first Docker version built entirely on the Moby Project. In case you’re new, Moby is an open framework created by Docker, Inc to assemble specialised container systems. It comprises of 3 basic elements: a library of containerised backend components (e.g., a low-level builder, logging facility, volume management, networking, image management, containerd, SwarmKit), a framework for assembling the components into a standalone container platform, and tooling to build, test and deploy artifacts for these assemblies and a reference assembly, called Moby Origin, which is the open base for the Docker container platform, as well as examples of container systems using various components from the Moby library or from other projects.

Docker for Mac is a Docker Community Edition (CE) app and aims for a native OSX experience that works with existing developer workflows. The Docker for Mac install package includes everything you need to run Docker on a Mac. Few of the attractive features it includes: 

  • Easy drag and drop installation, and auto-updates to get latest Docker.
  • Secure, sandboxed virtualisation architecture without elevated privileges. 
  • Native networking support, with VPN and network sharing compatibility. 
  • File sharing between container and host: uid mapping, inotify events, etc

The core building blocks for Docker for Mac includes –

  • Virtualisation
  • Networking
  • Filesystem

Some notable components include:

  • HyperKit, a toolkit for embedding hypervisor capabilities in your application
  • DataKit, a tool to orchestrate applications using a 9P dataflow
  • VPNKit, a set of tools and services for helping HyperKit VMs interoperate with host VPN configurations

Screen Shot 2017-07-13 at 10.01.33 PM

 

Screen Shot 2017-07-13 at 10.05.21 PM

 

Screen Shot 2017-07-13 at 10.08.09 PM

                                                                                                                                                                                            source ~ Docker Inc.

If you want to learn more details about these components, this should be the perfect guide.

LinuxKit today support multiple Cloud platforms like AWS, Google Cloud Platform, Microsoft Azure, VMware  etc. In terms of Local hypervisor, it supports HyperKit, VMware, KVM and Microsoft Hyper-V too. 

 

Screen Shot 2017-07-13 at 10.16.48 PM

 

If you have closely watched LinuxKit repository, a new directory called blueprint has been introduced which will contain the blueprints for base systems on the platforms that will be supported with LinuxKit.These has been targeted to include all the platforms that Docker has editions on, and all platforms that Docker community supports. All the initial testing work will be done under examples/ and then pushed to blueprints/ directory as shown. 

Currently, the blueprint/ directory holds  essential files for Docker For Mac 17.06 CE – 

  • base.yml => which contains the open source components for Docker for Mac.
  • docker-17.06.ce.yml => necessary YAML file to build up VM Image

The blueprint has support for controlling dockerd from the host via vsudd and port forwarding with VPNKit. It requires HyperKit, VPNKit and a Docker client on the host to run.

Screen Shot 2017-07-13 at 8.55.29 AM

File: docker-17.06-ce.yml

Screen Shot 2017-07-13 at 9.00.10 AM

The VPNKIT specific enablement comes from the below YAML code:

Screen Shot 2017-07-13 at 10.40.42 PM

File: base.yml

Screen Shot 2017-07-13 at 9.03.49 AM

Use the Moby tool to build it with Docker 17.06:

[simterm]

$moby build -name docker4mac base.yml docker-17.06-ce.yml

[/simterm]

Screen Shot 2017-07-13 at 10.09.33 AM

 

This will produce couple of files under docker4mac-state directory as shown below:

 

Screen Shot 2017-07-13 at 11.59.04 AM

 

Next, we can now run the LinuxKit command to run VM with 1024M disk

[simterm]

$linuxkit run hyperkit -networking=vpnkit -vsock-ports=2376 -disk size=1024M docker4mac

[/simterm]

By now, you should be able to see docker4mac VM booting up smoothly:

Screen Shot 2017-07-13 at 10.11.28 AM

Screen Shot 2017-07-14 at 10.07.12 PM

You can open up a new terminal to see the overall directory/files tree structure:

Screen Shot 2017-07-13 at 10.28.18 AM

 

Let us try listing the service containers using  ctr containers ls command. It should show up Docker For Mac 17.06 service container as shown below:

Screen Shot 2017-07-14 at 10.13.40 PM

Run the ctr tasks ls command to get the list of service containers:

Screen Shot 2017-07-16 at 10.30.49 AM

Now its easy to enter into docker-ddm service container with the below command:

[simterm]

$ctr exec -t –exec-id 861 docker-dfm sh

[/simterm]

Screen Shot 2017-07-16 at 10.33.07 AM

You can verify further information with docker info command:

Screen Shot 2017-07-16 at 10.36.49 AM

 

How to connect to docker-dfm` from another terminal?

Using another terminal, it is pretty easy to access docker via the socket guest.00000948 in the state directory (docker4mac-state/ by default) with the below command:

[simterm]

$docker -H unix://docker4mac-state/guest.00000948 images

[/simterm]

 

Let us create a Nginx docker container and see if it is accessible from Safari browser:

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

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

Know more what’s happening in LinuxKit project by visiting this link.

Have Queries? Join https://launchpass.com/collabnix

Ajeet Raina Ajeet Singh Raina is a former Docker Captain, Community Leader and Arm Ambassador. He is a founder of Collabnix blogging site and has authored more than 570+ blogs on Docker, Kubernetes and Cloud-Native Technology. He runs a community Slack of 8900+ members and discord server close to 2200+ members. You can follow him on Twitter(@ajeetsraina).
Join our Discord Server