The turret docking area was being incorrectly calculated many versions ago, this has been fixed. If your ship was made way back when, then when you spawn it in now, the docking area is too small. Can you redock those turrets without needing to add enhancers to the host ship's modules?
You can bypass the docking area with a setting in the server.cfg file. This will atleast let you spawn it in (in sandbox or home server modes) and edit the ship without them all running away. For online servers you are out of luck with the server.cfg setting (controlled by the person running the server).
IGNORE_DOCKING_AREA = false //ignores docking area size..... change this to 'true' to stop them flying off.