Use api for pulling images instead of shelling out

I've just copied the functions to parse and validate the repo name from Docker because otherwise this would require including the complete Docker sources.

/cc @brendandburns
Can you add a "TODO" comment explaining that we don'tr really want to be doing this and pointing at the docker issues?