The officials say the Sunday night counterattack in the besieged Ganfouda area also wounded another eight soldiers. The officials spoke on condition of anonymity because they aren't authorized to talk to reporters.
The Islamic State group claimed responsibility for the bombing in a statement circulated online.
Army spokesman Ahmed al-Mosmari says a push to retake the district is in "its last stage, and terrorist group leaders are besieged inside."
Ganfouda is one of the last two extremist-held areas in the east besieged by Libyan army troops that answer to Field Marshal Khalifa Hifter, who backs Libya's last elected parliament against rival militias loyal to the UN-backed government based in Tripoli.