I develop for a bunch of different platforms and devices. So I have a whole stack of different programming languages, SDK’s and IDE’s kicking around. This ends up being a huge pain in the ass to maintain. Try to temporarily use a different machine, or even worse. Upgrade? It is a constant download and configuration nightmare. I had a few of the ‘big environments’ all setup using vagrant which was great. But when I got my latest machine. It was going to be different. All my development environments were going to be defined as docker containers. ALL OF THEM. Even Arduino. This is the story of how I ‘deploy docker containers’ from OSX to Arduino boards.

After downloading and installing Boot2Docker, you need to install the VirtualBox extension pack. This extension adds the USB support that lets you share USB devices (like your Arduino) with virtual machines:

  1. Download the extension pack.
  2. Open up the VirtualBox GUI.
  3. Select ‘VirtualBox -> Preferences’ from the menu.
  4. Select the ‘Extensions’ icon.
  5. Press the funny lookin’ ‘yellow square superimposed on the blue box’ button.
  6. Browse to your downloaded extension pack, and press open.
Gif animation of how to install the virtual box extension pack.

Next we need to give Boot2Docker access to Arduino boards that you plug into your host machine.

  1. Plug your arduino into an available USB slot.
  2. Make sure the boot2docker-vm is not running.
  3. Right click on the boot2docker-vm and select ‘Settings…’
  4. Select the ‘Ports’ icon.
  5. Select the ‘USB’ tab.
  6. Make sure both ‘Enable USB Controller’ and ‘Enable USB 2.0 (EHCI) Controller’ is checked.
  7. Press the ‘green plus superimposed on blue USB plug’ button.
  8. Select the Arduino device from the list ‘FTDI FT232R USB UART’.
  9. Hit OK.
Gif animation of how to share arduino with boot2docker-vm.

Alright. Now VirtualBox is all configured to enable docker to access our Arduino. Time to roll a docker image that can punch containers into our Arduino. Well kind of. Docker won’t be running a container on the arduino. Running the container will just upload your sketch. For the image, I’m going to use ino. The latest versions of Arduino are starting to include its own official CLI. But at the time of writting it did not include a serial monitor, nor would it work headless (the CLI still needs a full X11 stack).

Your Arduino project needs to be in an inotool format and also contain the Arduino Dockerfile:

.
├── Dockerfile
├── lib
└── src
    └── sketch.ino

OK, with all that in place. It is time to build your image.

$ docker build -t your-arduino-project .

You can now ‘spin up a container’ on your Arduino.

$ docker run --privileged -v /dev/bus/usb:/dev/bus/usb your-arduino-project ino upload -m mega2560

Finally. Liberated from the blue Arduino IDE. Sorry Arduino. I love your microcontrollers. The IDE? Not so much.

A blue arduino heart logo

Edits:

  • 2015/04/10 - Miscellaneous typos.