Was the Buddha against violence in all situations? Is a strictly pacifist Buddhism exactly correct or are there certain situations were violence or war might be appropriate according to the Buddha's teaching?

  What did the Buddha say about the Military? 

  Given that Buddhist countries have soldiers, what doctrine[s] do they use to justify having a military to defend the people and the Dharma?

  Is there anything in the Tipitaka to support the idea that a soldier  who selflessly tries to defend others and/or the Dharma by violent means, makes good karma?
actually everything is in the suttas and for the purpose of the answer Buddhism i equate with Buddhadhamma, not sure what meaning the inquirer imparts it


  And how, householders, are there three kinds of bodily conduct not in
  accordance with the Dhamma, unrighteous conduct? Here someone kills
  living beings; he is murderous, bloody-handed, given to blows and
  violence, merciless to living beings.
  
  So, householders, it is by reason of such conduct not in accordance
  with the Dhamma, by reason of such unrighteous conduct that some
  beings here on the dissolution of the body, after death, reappear in
  states of deprivation, in an unhappy destination, in perdition, even
  in hell.


Saleyyaka sutta (MN 41)

one could be a Buddhist who got caught up in unfortunate circumstances where they are forced to use violence or a deadly force which they wouldn't use otherwise, but they'll still have to experience kammic consequences, which is normally birth in hell

such a kamma i think to a certain degree can be alleviated if the mind isn't clouded and blinded with defilements, first of all with desire of killing, at the time of its (the kamma) creation


  Again, with sensual pleasures as the cause, sensual pleasures as the
  source, sensual pleasures as the basis, the cause being simply sensual
  pleasures, men take swords and shields and buckle on bows and quivers,
  and they charge into battle massed in double array with arrows and
  spears flying and swords flashing; and there they are wounded by
  arrows and spears, and their heads are cut off by swords, whereby they
  incur death or deadly suffering. 
  
  Now this is a danger in the case of sensual pleasures, a mass of
  suffering visible here and now, having sensual pleasures as its cause,
  sensual pleasures as its source, sensual pleasures as its basis, the
  cause being simply sensual pleasures.
  
  Again, with sensual pleasures as the cause, sensual pleasures as the
  source, sensual pleasures as the basis, the cause being simply sensual
  pleasures, men take swords and shields and buckle on bows and quivers,
  and they charge slippery bastions, with arrows and spears flying and
  swords flashing; and there they are wounded by arrows and spears and
  splashed with boiling liquids and crushed under heavy weights, and
  their heads are cut off by swords, whereby they incur death or deadly
  suffering. 
  
  Now this is a danger in the case of sensual pleasures, a mass of
  suffering visible here and now, having sensual pleasures as its cause,
  sensual pleasures as its source, sensual pleasures as its basis, the
  cause being simply sensual pleasures.


Mahadukkhakkhandha sutta (MN 13)


  When a warrior strives &amp; exerts himself in battle, his mind is already
  seized, debased, &amp; misdirected by the thought: 'May these beings be
  struck down or slaughtered or annihilated or destroyed. May they not
  exist.' If others then strike him down &amp; slay him while he is thus
  striving &amp; exerting himself in battle, then with the breakup of the
  body, after death, he is reborn in the hell called the realm of those
  slain in battle. But if he holds such a view as this: 'When a warrior
  strives &amp; exerts himself in battle, if others then strike him down &amp;
  slay him while he is striving &amp; exerting himself in battle, then with
  the breakup of the body, after death, he is reborn in the company of
  devas slain in battle,' that is his wrong view. Now, there are two
  destinations for a person with wrong view, I tell you: either hell or
  the animal womb."


Yodhajiva sutta (SN 42.3)

one who is a Buddhist serving in a military during peace time with intent to slack on his duty at the high noon in favor of his obligations as a Buddhist, i think would be committing verbal misconduct of lying

Here's how Ajahn Sucitto of Cittaviveka Vihara describes his encounter with road bandits while on a pilgrimage in India


  Then everything blew up. Nick turned round with a menacing expression
  on his face; someone was tugging my robe on one side while the ﬁrst
  man was hauling frantically at the mug on its strap on the other.
  Three men charged at Nick who was crouched boxer-style; he wheeled and
  hit them with his backpack, then ran off with the three of them in hot
  pursuit. I was being lugged in two directions simultaneously by the
  strap on my water bottle and on my bag, I could only try to get the
  stuff off and let them have it, but their pulling on it made that
  impossible. We were going round in circles, with their excitement
  spinning into frenzy . I had to stop this. “Wait! Wait! Let me get
  this stuff off !” Momentarily they stood still. They all had axes and
  staves. The leader glared at me through twisted features and raised
  his axe.
  Funny how your mind goes clear when the options disappear. Why
  struggle against the inevitable? The only freedom was to go without
  fear. I bowed my head and pointed the top of my skull toward him, drew
  the blade of my hand along it from the crown of my head to the brow.
  “Hit it right there.” Something shifted; he backed off, waving his axe
  and muttering angrily. I stepped forward and repeated the action. Give
  it away; let it all go.
  Things settled. He lowered his axe. I slipped off the bag and the water 
  bottle and stepped back. The three of them began excitedly picking over
  the  treasure. I imagined that they’d rummage around, ﬁnd there was
  nothing there of any value, and run off. Two of them picked up the
  gear and scurried down the track away. I felt shaky and sat down.
  Better keep cool — I started chanting softly. Then Nick ambled along with a 
  smile but without his pack or assailants. “I’ve hidden the money;
  Bhante, are you all right?”
  His return signalled further frenzy. As his assailants returned, the men
  charged at him with their sticks and began swinging blows; Nick caught
  most of them on his arms: “ All right, all right! I’ll show you
  where.” And the mob had streamed off into the forest by the time that
  I got to my feet, leaving me with one lad, who sullenly resisted my
  attempts to strike up a conversation. But he was mellow compared to
  the older men when they returned — without Nick or the bags. They
  jumped on me and pulled off the bag that I had around my neck
  containing the relics and Buddha image; they ripped off the waistband
  that was threaded through my pouch; they clawed under my sabong and
  dragged the passport out of another pouch that was hanging around my
  waist.
  Then they were off with the loot tied up in bundles on their
  heads. The leader turned round and said “Your bags are over there,”
  pointing into the forest. “Fine, OK.” I said, in a vaguely warm way .
  The forest went back to silence as usual ... a sunny day, with the
  forested slopes on either side.  


"Rude Awakenings" (pp. 238-239)
https://www.youtube.com/watch?v=r9YE1oP-qr0#t=1h1m15s