Police say the blast struck around midday today as Iraqi troops were leaving the base in Taji, 20 kilometres, north of the capital.
They say 19 soldiers are among the dead. Hospital officials confirmed the casualties. All officials spoke on condition of anonymity because they were not authorised to talk to the media.
Insurgents in Iraq frequently target members of the country's security forces in an effort to undermine confidence in the Shiite-led government.
The attack was the deadliest in Iraq in several days and the second bombing apparently targeting soldiers near Taji in less than 24 hours.