Military discipline is the obedience to a code of conduct while in military service.
According to the U.S. Army Field Manual 7-21.13 4-4:
Discipline in the Army is one of the most basic elements of warfighting. Its purpose is to train you so you can execute orders quickly and intelligently under the most difficult conditions. Insistence on performing tasks properly enhances military discipline. For example, it means ensuring you wear your uniform properly, march well or repeating tasks until you perform them correctly. (...) Discipline in routine conduct such as saluting, police call, and physical training, can make discipline much easier to achieve when responding to more difficult conduct such as advancing under fire, refusing an illegal order, or moving a wounded Soldier to safety.