docker: refactoring collector logic.

related to #553.