According to a report of Xinhua news agency, the fire was brought under control after hectic efforts of about three hours.
Rafi Al Faruk, duty officer of the Fire Service and Civil Defense Headquarters in Dhaka, said the fire sparked suddenly and spread quickly, the report said.
"Bodies of five persons were retrieved after 10 firefighting units doused the blaze at around 2 p.m.," he said.
The official said that the cause of the fire and the extent of damage to the factory could not be ascertained immediately.