Recovering a docker vm on Windows with Virtual Box

NOTE: this is more of a windows / virtual box problem but the boot2docker experience as will a lot of things is not great on Windows… yet.

I was running the docker VM with 2 newly configured containers, all was going good, the docker part was quite easy (once up and running) then my entire machine crashed due to something else.

Reboot, open up shell and type ./boot2docker.exe start

Failed to start machine “boot2docker-vm” (run again with -v
for details)

So I run it with -v, no useful information.

Oh no.


Hopefully I haven’t lost the containers I spent a day setting up. The first windows issue with getting docker up and running was resolved by wiping all the data produced and starting fresh. That was not going to be the best outcome this time around.

First thing first, find out where that docker VM is:

virtual box UI

So it was in C:\Users\<username>\VirtualBox VMs\boot2docker-vm, there it was 580mb and several hours of work I didn’t want to do again, minor relief, made a copy of this.

Next step: getting docker back into a good state, I tried many combinations of; poweroff, reset, init, uninstalling and reinstalling, no luck. A note on this none of those commands hurt the vmdk file there, but still make a copy.

So next step move that boot2docker-vm folder out of there, and do a new init..

Small success docker starts.

Stop it and then try to drop the VMDK file back in…


Failed to start machine “boot2docker-vm” (run again with -v
for details)


Ok so now it’s starting to look like the problem is specific to VirtualBox and just getting the VM to spin up again. A little of bit of digging and I see the vbox file has some UIDs and MACAddresses, comparing the 2 newly-installed to the backup, the differences that look to be the cause appear.

diff of vbox file

Success, change those variables to match.

It starts, and the containers are there, phew!

docker ps -a

docker start <containerid>


It appears that a new init sets up new adapater MAC addresses and a new machine uuid, the rest of the differences can stay as they are specific to your old VMDK file. If you’re reading this good luck, and as always YMMV.

Using AutoMapper to help you map FSharpOption<> types


Because your model is structured this way, and you have realised you need this, otherwise this doesn’t apply to you.


When you get used to using AutoMapper to help you everywhere, you begin to demand it helps you everywhere by default. In this scenario you have to configure it to help you map from an F# type that has option (Guid is just an example).

In our event sourcing setup, we have commands that now change to have an additional property (not option), but the event now needs to have option (as that data was not always present).

We end up using those types/classes (events) that have the optional value to map to C# classes that are used for persistence (in this case RavenDB), and they are reference type fields so a null value is acceptable for persistence.

Here’s the Source and Destination classes, hopefully seeing that makes this scenario clearer.

public class SourceWithOption
    public string Standard { get; set; }
    public FSharpOption<Guid> PropertyUnderTest { get; set; }

public class DestinationWithNoOption
    public string Standard { get; set; }
    public Guid PropertyUnderTest { get; set; }

Note: the DestinationWithNoOption is the equivalent C# class that we get our of the F# types, so the F# code is really this trivial (SubItemId is the optional one):

type JobCreatedEvent = {
    Id : Guid
    Name: string
    SubItemId : option<Guid>


Where you do all your AutoMapper configuration you’re going to make use of the MapperRegistry and add your own.

(Note: all this code is up as a gist.

var allMappers = AutoMapper.Mappers.MapperRegistry.AllMappers;

AutoMapper.Mappers.MapperRegistry.AllMappers = () 
    => allMappers().Concat(new List<IObjectMapper>
            new FSharpOptionObjectMapper()

And the logic for FSharpOptionObjectMapper is:

public class FSharpOptionObjectMapper : IObjectMapper
    public object Map(ResolutionContext context, IMappingEngineRunner mapper)
        var sourceValue = ((dynamic) context.SourceValue);

        return (sourceValue == null || OptionModule.IsNone(sourceValue)) 
		? null : 

    public bool IsMatch(ResolutionContext context)
        var isMatch = 
		    context.SourceType.IsGenericType &&
				== typeof (FSharpOption<>);

        if (context.DestinationType.IsGenericType)
            isMatch &= 
			    != typeof(FSharpOption<>);

        return isMatch;

Tests to prove it

Here’s a test you can run to show that this works, I started using Custom Type Coverters (ITypeConverter) but found that would not work in a generic fashion across all variations of FSharpOption<>.

public void FSharpOptionObjectMapperTest()
    var allMappers = AutoMapper.Mappers.MapperRegistry.AllMappers;
    AutoMapper.Mappers.MapperRegistry.AllMappers = () =&gt; allMappers().Concat(new List
            new DustAutomapper.FSharpOptionObjectMapper()

    var id = Guid.NewGuid();
    var source1 = new SourceWithOption
        Standard = "test",
        PropertyUnderTest = new FSharpOption(id)

    var source2 = new SourceWithOption
        Standard = "test"
        //PropertyUnderTest is null

    var result1 = Mapper.Map(source1);
    Assert.AreEqual("test", result1.Standard, "basic property failed to map");
    Assert.AreEqual(id, result1.PropertyUnderTest, "'FSharpOptionObjectMapper : IObjectMapper' on Guid didn't work as expected");

    var result2 = Mapper.Map(source2);
    Assert.AreEqual("test", result1.Standard, "basic property failed to map");
    Assert.IsNull(result2.PropertyUnderTest, "'FSharpOptionObjectMapper : IObjectMapper' for null failed");

How much to scratch your own itch as a Startup?

Let me first define the itch concept – the itch here on in will refer to how far to take of your own opinions and desires of how a piece of software should operate.

So the question is from the title:

Q: How much to scratch your own itch as a startup?

Let me answer this right up front:

A: The correct amount.

Off the back of the Thursday night WDYK event, some Startup and User Experience talking points were raised that I wanted to discuss. I started off by trying to fit it in to the last post, but it didn’t quite fit there. I’m working in a Startupesque environment right now and just wanted to put some ideas down on ‘paper’, so here goes…


The statement that sent me off on this thought path was “don’t just scratch your own itch“, it’s good that Joel reminded the audience of this. Often as software developers we inject too much of our own usability ideas into the software being built. This falls over when we eventually realise this is not how typical users of our application would like to use it, even if they are other software developers. What I’m currently working on is not a core software engineer’s tool, say like bug tracking software. It is targeted at a specific type of user and process. But of course we developers often put our ‘application user’ hat on as we build features. Knowing that we’re building the system for someone other than ourselves doesn’t inhibit members of our development team from having strong opinions on how it should operate. This isn’t a bad thing…

Start scratching

There is something in the argument of “scratching your own itch” being beneficial – it is a reasonable starting point to turning your idea into a functioning application. But you always need to keep in mind your needs aren’t going to be exactly those of the customer. There’s a fair bit of this kind of opinion floating around on blogs: “Focusing on our own problems doesn’t necessarily mean we’re solving other people’s problems, or solving problems that matter at scale“- Ben Yoskovitz, source.

When subject matter experience/expertise comes in to play in building the application, you possibly are focussing on your interpretation of the problems that do matter. You can’t always get the cleanest/best problem definition from your users. So you go on to manage the itch combining the expertise and opinion with some user experience analysis. Your team probably has a vision of what the application will be about, heading towards hopefully at least one killer feature/aspect that makes your product stand out. So you go forward combining your ideas and refining with some user testing, now days focussed around the users experience and flow through the application.

Scratch right

This is how you get to that magical place which is the correct amount of scratching your own itch. Have the application be capable of (within reason) all you desire, but reign that in to simpler flows refined by actual results of real users navigating through the system to achieve their normal expectation of work supported by the system.

When my reaches that magical place, I’ll share what it took to get there, but for now it’s just an objective off in the not too far distance.

Scratch well

Joel describing his own start-up raised some great points about not needing venture capital, and how your product would likely be better off without it. There’s no financial pressure from the investor wanting to cash out sometime down the track. The way you do this is by:

1. Make something people want,
2. Make it better than what is out there,
3. Tell people about it.

That last point was a great theme to touch on, Mark had his ideas on this which were about going out to find your users, and not just shouting as he put it (a company blog, a company twitter account). Finding and engaging with users is critical. This is what it will take to get the widest range of feedback to help build your application. But it needs to be guided into a solution that’s not something that has come out of a very large handful of a ‘committee design meetings’.

As an FYI; Joel was Joel Friedlaender – Founder at Red Guava and Mark was Mark Mansour – Founder at Agile Bench

Web Directions South – What Do You Know? Night in Melbourne

Last night Thursday 23rd August 2012, I went along the What Do You Know? event held at The Appartment a great little place I used to frequent when I was working on Exhibition Street.

Earlier this year I was at the Web Directions South Code event, so anything put on the Web Directions South team is great and you should attend. In particular the up coming conference in mid October 2012, Sydney.

So back to Thursday nights event. There were 12 lightning talks, each 5 minutes long, I’ll list them off with links to what was most interesting / their entire presentation.

I wanted to talk about a few that stood out to me, mostly because it’s relevant to what is happening at Picnic Software at the moment.

The 4 presentations that stood out as very relevant to what we’re doing at Picnic Software were:

  • Mark – 5 Simple Things You’ll Forget When You Start a Startup
  • Joel – DevOps for Startups: Tales from the trenches
  • Matt – What the $%&# is UX Design?
  • Will – The User is Drunk

I started off by trying to fit it in to this post, but it ended up longer than I expected so it’s here: How much to scratch your own itch as a Startup?.

Summary of the event with links, in order of appearance:

The State of Our Web Performance Union
John Bristowe, @JohnBristowe

Content being deliver over the web is getting larger faster than bandwidth increases. Aim for performance. Have a look at a data trends

DevOps for Startups: Tales from the trenches
Lucas Chan, @geekylucas

Monitor and be ready for spikes. Uptime is critical. Don’t build what you can rent.

What the $%&# is UX Design?
Matt Magain, @mattymcg

Watch this on YouTube and check out

A whirlwind tour of D3.js
Tony Milne, @tonymilne

It’s very powerful, check it out

A brief introduction to the Gamepad API
Anette Bergo, @anettebgo

Getting Sourcey with Javascript
Michael Mifsud, @xzyfer

Source Maps are the future of debugging the web –

Startup Myths Debunked
Joel Friedlaender, @jfriedlaender

Named some common myths that are all likely wrong; failure is high e.g. 9 in 10 Startups fail, your idea is worthless, you need venture capital, the only costs are your time.

CSS checkboxes and the ridiculous things you can build with them
Ryan Seddon, @ryanseddon

50 handy things you’ve never heard of
Charlie Somerville, @charliesome

From zero to superpimp mobile web app using Tres
Julio Cesar Ody, @julio_ody

Julio amazingly wrote some non-trivial JavaScript using Backbone.js and his library:

The User is Drunk
Will Dayble, @willdayble

Good UI is ‘not there’, say things twice (icon and words), you can’t beat over the shoulder testing (watching your user).

5 Simple Things You’ll Forget When You Start a Startup
Mark Mansour, @markmansour

Marketing (is critical and not easy), Product (focus on benefits and customers), Promotion (talk to customers), Price (Tiers and known costs for customers), Place (don’t shout at your customers, go find them)

Automating IIS actions with PowerShell – Create Multiple Sites

I’m working towards a more complex SignalR based post, but in the mean time part of the work on that involves setting up a few ASP.NET web apps.

If you’re after a more comprehensive guide check out this post on by Thomas Deml. I’ve summarised the steps required to get some basic .NET 4 web applications deployed.

To create N identical websites in local IIS, each with an incrementing name Id. Each linked to the same application directory. The exact reason as to why will come in a future post, for now consider it an exercise in manipulating IIS via PowerShell.

Step 1 – Ensure you’re running the scripts in x86 mode.

Which seems quite common a problem, with a stackoverflow question. I haven’t worked a way around this yet, but this is the error when not running as x86:

New-Item : Cannot retrieve the dynamic parameters for the cmdlet. Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154.
At line:1 char:9
+ New-Item <<<< AppPools\test-app-pool
+ CategoryInfo : InvalidArgument: (:) [New-Item], ParameterBindingException
+ FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.NewItemCommand

Step 2 – Import-Module WebAdministration
This loads the IIS namespace which allows you to just navigate in the same way you would the filesystem

> CD IIS:\

Step 3 – Create & Configure App Pool

    New-Item AppPools\test.pool

    Set-ItemProperty IIS:\AppPools\test.pool -name "enable32BitAppOnWin64" -Value "true"

    Set-ItemProperty IIS:\AppPools\test.pool -name "managedRuntimeVersion" -Value "v4.0"

NOTE: here I didn’t have any luck storing the app pool path in a variable then using Set-ItemProperty, hence the repeating.

Step 4 – Variables

    $sitesToCreate = 10
    $path = "C:\dev\project-x\App.Web"
    $appPool = "test.pool"

Step 5 – Create Site & Link AppPool Loop

For N(10) to zero:

  • Create a new site
  • Set binding info and physical path
  • Set the app pool
    while ($sitesToCreate -gt 0)
        $siteName = "s" + $sitesToCreate + ".site.local"
        $siteWithIISPrefix = "IIS:\Sites\" + $siteName
        Write-Host "Creating: " $siteName
        $site = New-Item $siteWithIISPrefix -bindings @{protocol="http";bindingInformation="*:80:" + $siteName } -physicalPath $path
        Set-ItemProperty IIS:\Sites\$siteName -name applicationPool -value $appPool

Note: ‘appPool’ is a text variable, not the ‘Get-Item’. Set-ItemProperty operates on a path not a variable representing the item.

We’re done

One last note, to get these to resolve correctly on your local developer machine you’ll need to modify your hosts file.

IIS multisite

The complete code up as a Github Gist.

Web Directions Code Melbourne 2012 – Day 2


After a great 1st day at #WDC12. The small end-of-day-one-party was hosted at LaDiDa, with some booked dinners around Melbourne with some of the locals (which sadly I wasn’t able to attend). None the less we got right into it with an interesting start to day two.

Dmitry Baranovsky
JavaScript: enter the dragon
This was quite an eye opening and scarily entertaining motivational address by Dmitry. The phrase ‘You Suck’ was uttered the right number of times to motivate an audience full of developers to strive to be better at JavaScript, software development in general and even physically fitter.

The forced take away was to be aware of the intricacies of JavaScript by actually reading the language specification PDF link and (annotated here) and to build your own JavaScript six-pack:

  • Types and type coercion
  • Operators + ==
  • Objects and primatives
  • Functions and constructors
  • Closures
  • Prototype

Jed Schmidt
NPM: Node’s personal manservant
For those familiar with the .NET world, Jed is a Hanselman grade presenter, with great delivery of a comedy element to deliver a presentation as funny as it is educational. Jed introduced many concepts around package management for node (NPM) he built a small demonstration framework to walk us through various concepts, the readme file contains a complete list of everything he covered.


Jared Wyles
Removing the gag from your browser
Jared delivered a very usefully technical presentation around effectively using the Chrome Developer Tools to trouble shoot, analyse and track site performance. The most important take away was being aware of all the network timing elements for your site when it’s served to a user for the first time, and ensuring items are cached correctly for subsequent visits. He covered using the memory and CPU snapshot and measurement tools to trace any memory leaks and code inefficiencies in particular around interrogating/traversing the dom.

Anette Bergo
Truthiness, falsiness, and other JavaScript gotchas
Anette took the audience through some of the stranger parts of the JavaScript language where it’s likely anyone who hasn’t experienced any of those particular bug prone approaches may run in to trouble. Some key ones to be wary of that you may expect to not really cause problems were:

  • ParseInt()
  • Operators and coercion

Damon Oehlman
The main event: beyond event listeners.
Damon gave us an introduction to eve – an eventing library, just check it out.

Mark Dalgleish
Getting closure
Mark covered “Immediately Invoked Function Expressions” and some of the benefits like protecting against unwanted global variables, and ensuring scope, along with explaining the closure concept. His detailed slides are up on his blog.

Ryan Seddon
Debugging secrets for lazy developers
Ryan‘s theme was automation, get as much of your repeatable tasks scripted. He walked through using headless browsers via Travis-CI, but reminded us that will only get you so far you need to test in real browsers too. An exciting little project of his is a port of the Yahoo Yeti tool, to work without the YUI test runner, his is called Bunyip and should be available soon.

Tony Milne
Party like it’s 1999, write JavaScript like it’s 2012!
Tony covered an issue with dependencies in JavaScript when your chain of references gets larger, and how ideally the responsibility to link required JavaScript files should exist in a better place than just the html files. He mentioned Require.js is great for in browser use, but the really great ones exist for server side JS.

Tony Milne 2012 style JS

Tim Oxley
Clientside templates for reactive UI
Tim was a another entertaining presenter with some choice phrases to compare and contrast developers he admires and frameworks that support development of thick-clients. Tim had a sweet spot for 3 templating frameworks Dot, Jade and Handlebars.js (where Handlebars > Hogan > Mustache )

Rob Hawkes
HTML5 technologies and game development

Rob stole the show in terms of general inspiration and being uplifting with his love of games and how it helps build better online experiences in particular in browser technologies. The vision he presented was a world where the browser platform, in particular on mobiles extended the gaming experience from the desktop world instead of only partially emulating it. Rob mentioned a few interesting APIs/concepts/products worth checking out like; WebWorkers and PointerLockAPI and TinkerCAD. Rob works for Mozilla the not-for-profit software foundation that gets so much amazing stuff done with only 600 employees only half of which are developers, so if you want to see what’s coming up check out Firefox Aurora, or what’s being worked on right now Firefox Nightly and if you want to get in touch with anyone at Mozilla find them on IRC.

The conference wrapped up at The Carlton down Bourke Street in an awesome after party where beer fueled discussions could run rampart.