Add dockerfile pod template and fix state transition bugs