This is a common misconception. The injunction is only against unlawful (or more broadly, non socially sanctioned) killings. Killing while engaged in warfare is acceptable by this code.
It doesn't say "thou shalt not kill unlawfully" or "thou shalt not kill without social sanction". It says "thou shalt not kill". Period. Nowhere in the Bible is any condition or qualification placed on this commandment.
Reconciling this commandment with all the killing in the Bible that God has no problem with is not as easy as you want it to be.