provision/docker: Removing some duplicated code and refactoring