A test Docker-BSDPy environment

Some Mac Admins have recently blogged about testing BSDPy using Docker:

I decided to try it out in a setup that suited me. Here’s how it went.

What is BSDPy?

Put simply, BSDPy is an alternative to Apple’s NetBoot/NetInstall. The premise is to provide a NetBoot/NetInstall service from a Linux host, removing another necessity for an OS X Server. Since Apple stopped providing server-grade hardware, this has been on Mac Admins’ agendas.

The posts above details all the reasons for trying this. This post is not intended to replace those posts, simply to document the set up I used to get this working.


My set up is a MacBook Air, with 8GB RAM, and the following programs installed:

  • VirtualBox
  • VMWare Fusion (version 6). Version 7 will work. Note this isn’t a free program, but is required to test NetBooting an OS X VM. If you have a spare physical Mac on your network, you can use this instead.
  • DeployStudio
  • Vagrant
  • TextWrangler with Command Line Tools – this enables the edit command. You can substitute nano or vi or another editor.

Side note: I use AutoPkg to install TextWrangler, VirtualBox and Vagrant.

1. Setup VMWare Fusion

My setup was based on instructions on Der Flounder’s blog: https://derflounder.wordpress.com/2013/01/23/building-mac-test-environments-with-vmware-fusion-netboot-and-deploystudio/

  • Open VMWare Fusion, click on File > New
  • Drag “Install OS X Yosemite.app” (you already got this from the App Store, right?) into the “Install from Disk or Image” window
  • Allow the standard setup for OS X 10.10, but press “Customise” before launching.
  • In the “Startup Disk” pane, set the VM to boot to the “Network Adapter NAT”.
  • Leave VMWare Fusion open (but don’t start the VM) while you perform the remaining tasks – you need the virtual network interface to be active.

2. Setup Vagrant

I used a CentOS VM to better emulate my shop’s configuration.

If you wish, you can just clone the Vagrantfile and startup.sh shown below using git, and move on to Step 4:

$ mkdir -p ~/vagrant/docker-bsdpy
$ git clone https://github.com/grahampugh/docker-bsdpy-vagrant.git ~/vagrant/docker-bsdpy

Otherwise, carry on reading to create the files yourself:

$ mkdir -p ~/vagrant/docker-bsdpy/nbi
$ cd ~/vagrant/docker-bsdpy
$ vagrant init chef/centos-7.0
$ edit Vagrantfile

Vagrantfile should have the following contents:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "chef/centos-7.0"

  config.vm.network "public_network"
  config.vm.synced_folder '.', '/vagrant', disabled: true
  config.vm.synced_folder '.', '/usr/local/docker', {:mount_options => ['dmode=777','fmode=777']}


This config allows us to populate ~/vagrant/docker-bsdpy with scripts, and ~/vagrant/docker-bsdpy/nbi with our NetBoot Images, so we don’t need to manually copy them into the VM.

3. Create a Startup script which will be used to setup the Docker BSDPy environment

$ cd ~/vagrant/docker-bsdpy
$ edit startup.sh

The contents of startup.sh. The ETH variable is the network interface you are going to use. In my case, the virtual interface created by my VMware Fusion installation (enp0s8) worked best. You may get away with eth0 or eth1. Experiment!:


# Set this to match the valid interface

# Setup machine
yum update -y
yum install -y nano docker-io
service docker restart
chkconfig docker on

# Pull
docker pull hunty1/bsdpydocker

# Clean up
docker stop bsdpy
docker rm bsdpy

# Run
chmod -R 777 /usr/local/docker/nbi
IP=`ifconfig $ETH | awk '/inet / {print $2}' | sed 's/ //'`
echo $IP

docker run -d \
  -p \
  -p \
  -p \
  -v /usr/local/docker/nbi:/nbi \
  -e DOCKER_BSDPY_NBI_URL=http://$IP \
  --name bsdpy \
  --restart=always \

4. Make a DeployStudio NetBoot Image

Or use an existing one. I won’t go through GUI snapshots. Just make sure Python is enabled, and it’s set to HTTP type (not NFS). Once created, you need to move or copy it to the nbi folder and make some tweaks:

$ cp /Library/NetBoot/LibrarySP0/OSX-NETBOOT.nbi ~/vagrant/docker-bsdpy/nbi/
$ cd ~/vagrant/bsdpy/nbi/OSX-NETBOOT.nbi
$ rm NetInstall.dmg
$ mv NetInstall.sparseimage NetInstall.dmg
$ edit NBImageInfo.plist

You may wish to remove the entries from the DisabledSystemIdentifiers array. You should also ensure the following keys are set as follows:


5. Vagrant up!

It’s time to start up your virtual Linux server.

$ chmod 755 startup.sh
$ vagrant up

You will be asked to select a network interface. On my tests, vmnet8 was the correct choice.

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'chef/centos-7.0' is up to date...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Available bridged network interfaces:
1) en1: Wi-Fi (AirPort)
2) en0: Ethernet
3) p2p0
4) vmnet1
5) vmnet8
==> default: When choosing an interface, it is usually the one that is
==> default: being used to connect to the internet.
    default: Which interface should the network bridge to? 5

Now, we are ready to run the startup script. If all goes well, you should be able to netboot to your NBI!

$ vagrant ssh -c 'sudo /usr/local/docker/startup.sh'

My setup encountered problems with a VirtualBox Guest Additions mismatch. YMMV. This is why I haven’t set startup.sh to run in the Vagrantfile. You can uncomment it from the Vagrantfile if you want to try this out, and can certainly uncomment for subsequent vagrant ups. These commands fixed it:

$ vagrant ssh -c 'sudo yum update -y'
$ vagrant ssh -c 'sudo /etc/init.d/vboxadd setup’

If you encountered this too, you’ll get an error about needing to install a new kernel-devel-3.* package. Copy the version into the command:

$ vagrant ssh -c 'sudo yum install gcc yum install kernel-devel-3.*' ### copy the full path from the error message
$ vagrant ssh -c 'sudo /etc/init.d/vboxadd setup’
$ vagrant reload

6. Boot your VMWare Fusion VM

Boot up your VMWare Fusion OS X VM. If all goes well, you’ll see the VMWare boot screen, attempting to boot from EFI Network, and then the OS X boot screen with spinning globe:
Screen Shot 2015-04-29 at 22.25.04

Screen Shot 2015-04-29 at 22.25.08

To check what’s going on, you can monitor the log:

$ vagrant ssh -c 'sudo docker logs -f bsdpy'

Screen Shot 2015-04-29 at 22.29.11

Here’s my very first virtual DeployStudio workflow window!

Screen Shot 2015-04-29 at 19.54.01


One thought on “A test Docker-BSDPy environment

  1. Patrick

    Great instructions! FYI, I was able to set this up but I had to change the DOCKER_BSDPY_* variables to BSDPY_* in order for my environment to work. Otherwise, BSDPy uses as its external IP.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s