Two women and a child are among the dead, according to a medic from Baghdad's Al-Kindi hospital, and is the second deadly suicide attack in Iraq within 24 hours.
The attack took place near Sadr City, an impoverished district that is the stronghold of radical Shiite cleric Moqtada al-Sadr.
Earlier, at least 15 people were killed when a suicide bomber blew himself up amid dozens of police recruits in a queue outside police headquarters in the former rebel bastion of Fallujah, west of Baghdad.
A few hours before the courthouse bombing, Brigadier General Mohammed Raza Abdellatiff, who was in charge of logistics for the Iraqi army in Baghdad, was shot dead by gunmen as he was driving through the capital's western Yarmuk district.
In another attack, gunmen shot dead a driver working with Baghdad's human rights ministry.
Deliberations continue
The latest violence comes as negotiations over the formation of Iraq's national unity government continue.
A Shiite MP said the dominant Shiite alliance will retain the crucial interior ministry post in the new cabinet.
"Discussions are still on with all the parliamentary blocs but the decision on the interior ministry is sealed and that will be with the Shiite alliance," Shirwan Alwali said.
The outgoing Shiite-run interior ministry has been accused by Sunni Arabs of operating death squads that have carried out extra-judicial killings of members of the once powerful community in the ongoing sectarian violence.
The country's former Sunni Arab elite is demanded five ministries in the new national unity government, in addition to the post of deputy prime minister, a top Sunni leader said.
