NATO and Afghan authorities have launched an investigation, the international military coalition said.
NATO declined to identify the nationalities of the victims. The majority of forces in eastern Afghanistan are American.
The incident occurred in Pachir Wagam district of eastern Nangarhar province, according to an Afghan official who spoke on condition of anonymity because the information was not officially released.
It was not immediately clear if the gunman was a police officer or someone who had infiltrated the training mission. In the past, insurgents have donned police or army uniforms to attack Afghan government installations.
There have also been a number of incidents in which Afghan police officers turned on their trainers in deadly shootouts. In July, there were two shootings of Western troops by one of their Afghan counterparts.
On July 20, an Afghan army sergeant opened fire at an army base in northern Afghanistan, outside Mazar-e-Sharif, killing two American civilian trainers before being shot dead. That followed an attack in the south on July 13, when a soldier killed three British troopers, including the company commander, with gunfire and a rocket-propelled grenade in the dead of night in southern Helmand province.
Also, in November 2009, an Afghan policeman killed five British soldiers at a checkpoint in Helmand.
Such shootings highlight the potential hazards of a push to speedily expand Afghanistan's army and police forces in the next few years. The goal is to turn over the responsibility for nationwide security to Afghan forces by 2014 so that NATO forces can go home.
In the past year, the Afghan police force grew 27 percent to 120,500 officers from about 95,000. The army grew 42 percent to about 138,200 soldiers from 97,000.