Like most people, I use Mac, Windows as well Linux OS for development and testing purposes. Primarily I use Mac for Development purpose. I have few projects which uses SQL Server as Data Storage Layer. Setting up Docker Container on Mac and Opening up the ports was pretty easy and doesn’t take more than 10 Minutes. Steps followed: Install. Docker Desktop is an application for MacOS and Windows machines for the building and sharing of containerized applications and microservices. Docker Desktop delivers the speed, choice and security you need for designing and delivering containerized applications on your desktop.
![Desktop Desktop](/uploads/1/2/9/2/129202856/428374003.jpg)
If you've been struggling with this issue and just want an answer, skip to the bottom for the TL;DR. I won't fault you for it.
Docker is a great tool for deploying web services, but one of my favorite uses for it is standardizing toolchains. Instead of everyone on the team needing to setup their development environments identically, and then keep them in sync, you define the build tools in a single place, a docker image. Then everyone, including your build server, uses that single pre-packaged image.
Not only is this great for teams, but it's also fantastic when you have side projects that you only periodically revisit. Without fail, when I come back to some old project, I've since updated my tools for something newer, and I can't build that old project without either upgrading the project or degrading my tools. Leaving a build tools image behind means I can just pick it up and work on it without spending a day getting back up and running.
It's not all sunshine and roses though. I went on quite an adventure today. Last year I put on a TDD for Arduino workshop. I had started to create a Docker image for AVR development, but ran into problems when it came time to flash the program to the board. Exposing a USB port to a docker container on Mac isn't exactly a trivial task (until you know how at least!). For that session we mobbed, so I only had to setup one machine. I just stopped fighting with it and went with a regular install of the tools on my machine.
Recently though, I've taken a renewed interest in getting this to work properly. First, I've been playing with ARM development, but there's a bug in AVR and ARM's compiler packaging that means you can't have both toolchains installed at the same time. Having these toolchains containerized means I can easily keep both readily available. Secondly, I'm now beginning to build on that workshop to turn it into an 'Intro to Bare Metal Programming' course. For that, I really need to be able to hand folks an environment I know works, so we're not spending more time working kinks out of dev setups than learning. Also, in order to standardize embedded toolchains for a team or client at work, I really need to know how to get USB working on Mac.
If you're running Linux, this is as simple as adding
--device /dev/ttyUSBx
to the docker run command. Needless to say, it's not that simple on OSX or Windows. That's because the docker daemon only runs natively on Linux. For other operating systems it's run in a hypervisor or virtual machine. In order to expose the port to the container, you first have to expose it to the virtual machine where Docker is running. Unfortunately, hyperkit, the hypervisor that Docker-For-Mac uses doesn't support USB forwarding.Since we can't expose a USB port to the native Mac Docker hypervisor, we have to fallback onto
docker-machine
, which uses a Virtualbox VM to host the dockerd
daemon. There are great instructions for setting up docker-machine with a USB filter, but I was getting a lot of mysterious segfaults from docker-machine
that would leave my VM running, but also unable to recover a connection to it through docker-machine. It turns out that several versions of VirtualBox had a bug causing the segfaults. Upgrading to v6.06 solved that problem, but I still couldn't see the device. It took me too long to remember that I had the same trouble with USB 3.0 a few months ago with a Windows guest OS. Dropping down to USB 2.0 fixed that issue.Okay, let's get down to business and get a fully containerized embedded toolchain running on Mac.
First, download and install VirtualBox version 6.06 or greater. Again, this must be version 6.06 or greater or you'll see segfaults when trying to create a USB filter later. You can optionally install the VirtualBox extension pack. I recommend it though, because it enables USB 2.0, which results in faster programming times.
Next, we can create and setup our
docker-machine
(virtual machine).Now go ahead and plug in your device and run this command to verify that containers can see it.
If the command fails, make sure your device is plugged in and visible to the VM. You may have mistyped the vendor and product ids, or the tty may be attached under a different number.
That's it. Like I said, it's really easy once you know how. Unfortunately, there's not official documentation and, considering that both
docker-machine
and boot2docker
are in maintenance mode, I'm hoping we get official support for USB on hyperkit in the future. Containerizing build tools is a great way for teams to take advantage of the technology even if you're not using them to deploy services. Now, if you'll excuse me, I need to go update my AVR toochain image with a script to do this and add in avrdude
for uploading programs.Until next time,
Semper Cogitet
Semper Cogitet
Docker Desktop For Mac Download
Installing Kitematic
Download Kitematic
Docker For Mac Os
Download Kitematic, unzip it and double-click the application to run it.
Initial Setup
Opening Kitematic for the first time sets up everything you need to run Docker containers. If you don’t already have VirtualBox installed, Kitematic will download and install the latest version.
All Done! Within a minute you should be ready to start running your first container!
Docker Mac Download
Technical Details
Kitematic is a self-contained .app, with a two exceptions:
- It will install VirtualBox if it’s not already installed.
- It copies the
docker
anddocker-machine
binaries to/usr/local/bin
for convenience.
Install Docker For Mac
Why does Kitematic need my root password?
Kitematic needs your root password for two reasons:
- Installing VirtualBox requires root as it includes Mac OS X kernel extensions.
- Copying
docker
anddocker-machine
to/usr/local/bin
may require root permission if the default permissions for this directory have been changed prior to installing Kitematic.