refactored docker code for better reuse.