Docker: Introduction and How-To Access natively from Mac OS

Eat

I have been exploring Docker technology for projects leveraging Node.js. My experimentation was all on my Retina Mac Book Pro – running Yosemite. Docker is a relatively new breed of virtualization technologies known as Containers. A commonly used analogy for Docker is to compare it to actual real-life containers or lego bricks: it provides a fundamental unit, and with it a way for an application to be portable and moveable, regardless of hardware.

The all-new Things Things is the award-winning personal task manager that helps you achieve your goals. This all-new version has been rethought from the ground up: it’s got an all-new design, delightful new interactions, and powerful new features. Google Photos is the home for all your photos and videos, automatically organized and easy to share.

Here is a quick snapshot from the “What is Docker?” page:

“Docker” encompasses the following:

  • Docker client: this is what’s running in our machine. It’s the docker binary that we’ll be interfacing with whenever we open a terminal and type $ docker pull or $ docker run. It connects to the docker daemon which does all the heavy-lifting, either in the same host (in the case of Linux) or remotely (in our case, interacting with our VirtualBox VM).
  • Docker daemon: this is what does the heavy lifting of building, running, and distributing your Docker containers. (Refer to the “Docker Engine” in the diagram above)
  • Docker Images: docker images are the blueprints for our applications. Keeping with the container/lego brick analogy, they’re our blueprints for actually building a real instance of them. An image can be an OS like Ubuntu, but it can also be an Ubuntu with your web application and all its necessary packages installed.
  • Docker Container: containers are created from docker images, and they are the real instances of our containers/lego bricks. They can be started, run, stopped, deleted, and moved.
  • Docker Hub (Registry): a Docker Registry is a hosted registry server that can hold Docker Images. Docker (the company) offers a public Docker Registry called the Docker Hub which we’ll use in this tutorial, but they offer the whole system open-source for people to run on their own servers and store images privately.

Docker is a Linux technology, so it doesn’t run natively on Mac OS X. So we need a Linux VM to run the containers. There are two ways this could be done on a Mac OS X:

  • Use Docker’s Mac OS X approach. This involves using Boot2Docker – that has a built-in Linux Machine. This is straight-forward and well described. The boot2docker tool makes this about as easy as it can be by provisioning a Tiny Core Linux virtual machine running the Docker daemon and installing a Mac version of the Docker client which will communicate with that daemon.
  • Use a VM such as VirtualBox or VMWare Fusion – run Linux as the Guest OS in the VM. I will be covering this approach – there are several blog posts covering doing it with VirtualBox. The challenge with this approach, unlike, the boot2docker approach – is that all Docker commands need to be handled in the by logging into the Linux VM. This post gets into how to get native-ish experience on your Mac but you’re running a Docker host that doesn’t work with boot2docker specifically the Docker host is running on Ubuntu Trusty host running as a VMWare Fusion Guest OS.

The Basics:

1. I have a Ubuntu 64-Bit (Recommended for Docker) 14.04.02 Server (Command Line Only) installed as one of the Guest OSes under VMWare Fusion. I am using VMWare Fusion 7.1.2.

2. Install Docker following instructions from the Ubuntu/Linux section. There are prerequisites that need to be taken care of if you are running something other than Ubuntu Trusty 14.04. The install primarily involves the following command (details in the link above):

3. Our goal is to run Docker commands from Mac OS X terminal. The trick is to know that the Docker client does all of its interaction with the Docker daemon through a RESTful API. Any time you use docker build or docker run the Docker client is simply issuing HTTP requests to the Docker Remote API on your behalf. So we need to open up a “communication channel” and making the API to the Docker host in the virtual machine accessible to Mac OS X. Two steps are involved:

– Edit the /etc/default/docker file in Ubuntu Trusty to the line shown below

and then restart the Docker service:

4. The following command from the Ubuntu OS won’t work now since Docker access through a TCP Connection:

This on the other hand should work:

5. Now we need to forward the IP Address / Port so that the Docker commands can be issued from Mac OS X. This involves configuring the VMShare Fusion NAT Settings for the Ubuntu Trusty Guest OS. We know we need to forward Port 2375. In addition we need to get the IP Address of the Docker engine or Docker Host running in Ubuntu. The way to get that is to run the command

This will dump the networking settings – look for docker0 – and note down the IP Address. In my case it was 172.17.42.1. This is important to understand. We are NOT looking for the IP Address of the Guest OS or the eth0 of the Guest OS but the Docker Host IP Address.

Next run ‘ifconfig‘ on the Mac OS X terminal, and getthe IP Address or rather the Adapter name assigned to the Ubuntu Guest OS. I have two Guest OSes installed – Windows 8.1 and Ubuntu Trusty. When I run ‘ifconfig’ command – I see a number of networking interfaces – and two that are labeled ‘vmnet1‘ and ‘vmnet8‘. The way to ensure that you pick the right interface is to look at the IP Address assigned to the ‘vmnet‘ in Mac OS X, and look at the eth0 interface in the Ubuntu Trusty. Pick the one that is on the same subnet, here is what I had:

Now that we know what instance we have to deal with for the VMWare Fusion – we need to modify the nat.conf for the right instance, I will use vmnet8 as the example:

In this file look for the [incomingtcp] section, and add the following:

The format of this section is <external port number> = <VM’s IP Address>:<VM’s Port Number>. Note in the above example – the IP Address used for the VM’s IP Address is actually the address of the docker0 interface provided in the ifconfig command when run in Ubuntu.

Eat All The Things Mac Os Download

6. We are close now. Make sure that you have brew on your Mac OS X (if you are developing on Mac, you probably already have it!). Install the Docker client in Mac OS X using (you :

The last command should tell you if Docker was installed correctly and the version number. Assuming you have installed Docker on the Ubuntu Guest OS and Docker client on Mac OS X using brew minutes apart – you would have the latest version and they would be the same. The versions have to be identical for this to work.

7. Now you are set to access Docker commands from the Mac OS terminal, run the same command as above

Eat All The Things Mac Os 11

and it should work. The -H flag instructs the Docker client to connect to the API at the specified endpoint (instead of the default UNIX socket).

To avoid typing the flag, and the endpoint followed by the command add the following export, and you can access all Docker commands as you would natively.

Docker Away!

NOTE:

Opening/forwarding ports on the OS is NOT recommended on Production Environments. This is merely to ease development effort if you are doing it on your own Mac Book.

It was two decades ago to the day—March 24, 2001—that Mac OS X first became available to users the world over. We're not always big on empty sentimentality here at Ars, but the milestone seemed worthy of a quick note.

Of course, Mac OS X (or macOS 10 as it was later known) didn't quite survive to its 20th birthday; last year's macOS Big Sur update brought the version number up to 11, ending the reign of X.

But despite its double life on x86 and ARM processors and its increasingly close ties to iOS and iPadOS, today's macOS is still very much a direct descendant of that original Mac OS X release. Mac OS X, in turn, evolved in part from Steve Jobs' NeXT operating system—which had recently been acquired by Apple—and its launch was the harbinger of the second Jobs era at Apple.

Cheetah, Mac OS X's initial release, was pretty buggy. But it introduced a number of things that are still present in the operating system today. Those included the dock, which—despite some refinements and added features—is still fundamentally the same now as it ever was, as well as the modern version of Finder. And while macOS has seen a number of UI and design tweaks that have changed over time, the footprints of Cheetah's much-hyped Aqua interface can still be found all over Big Sur.

Advertisement

OS X brought many new features and technologies we now take for granted, too. For example, it enabled Apple's laptops to wake up from sleep immediately, and it introduced dynamic memory management, among other things.

Mac OS X's greatest impact in retrospect may be in the role it had in inspiring and propping up iOS, which has far surpassed macOS as Apple's most widely used operating system. And indeed, macOS lives in a very different context today than it did in 2001. It was recently bumped from the No.2 operating system spot globally by Google's Chrome OS, ending a very long run for Mac OS as the world's second-most popular desktop operating system in terms of units shipped.

The most popular desktop operating system in 2021 is Windows, just as it was in 2001, but the most popular OS overall is Google's Android, which has dramatically larger market share in the mobile space than iOS does.

So while Mac OS X's influence is profound, it exists today primarily as a support for iOS, which is also itself not the most popular OS in its category. Despite Apple's resounding success in the second Steve Jobs era, as well as in the recent Tim Cook era, the Mac is still a relatively niche platform—beloved by some, but skipped by much of the mainstream.

After 20 years, a lot has changed, but a whole lot has stayed the same.