Five prisoners and three soldiers were killed in a failed attempt by some inmates to break out of a prison in the Somali capital.