Move setting hostConfig and pulling images into helper functions.

This refactor is being submitted as a separate PR from https://github.com/dotcloud/docker/pull/4548/files.

Docker-DCO-1.1-Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)