The attack targeted a checkpoint along a route used by pilgrims in the northern Baghdad neighbourhood of al-Shaab.
Police officials say four soldiers are among the dead.
It was the first attack on Shia pilgrims in Baghdad during the lead-up to the religious commemoration known as Arbaeen, when Shia faithful converge on the holy city of Karbala.
The annual commemoration is often marked by violence despite tight security measures to protect the pilgrims, many of whom travel to Karbala on foot.
Iraq's military command has told civilians in the Islamic State-held Ramadi to leave the city, a sign that an operation may soon be underway to retake the provincial capital.
Today's statement, broadcast on Iraqi state TV, says the Ramadi families are requested to leave the city from its southern, Himaira area. No further instructions or details were given.
It's unclear if the long-awaited operation to recapture Ramadi is imminent. The US-led alliance carried out seven airstrikes near Ramadi on Saturday, targeting IS fighters, key positions and weapons caches.
The Sunni extremist group controls large swaths of territory in Iraq and neighbouring Syria.
