In 1941, bugler and career soldier Private Robert E. Lee Prewitt (Montgomery Clift) transfers to a rifle company at Schofield Barracks on the island of Oahu. Captain Dana "Dynamite" Holmes (Philip Ober) has heard he is a talented middleweight boxer and wants him to join his regimental team to secure a promotion for Holmes. Prewitt refuses, having stopped fighting because he blinded his sparring partner and close friend over a year before. Holmes and Prewitt are both adamant.
Holmes makes life as miserable as possible for Prewitt, hoping that he will give in. Holmes orders First Sergeant Milton Warden (Burt Lancaster) to prepare general court-martial papers after Sergeant Galovitch (John Dennis) first insults Prewitt and then gives an unreasonable order that Prewitt refuses to obey. Warden suggests, however, that he try to get Prewitt to change his mind by doubling up on company punishment. The other non-commissioned officers join the conspiracy. Prewitt is supported only by his friend, Private Angelo Maggio (Frank Sinatra).
Meanwhile, Warden begins an affair with Holmes' neglected wife, Karen (Deborah Kerr). Warden tells Karen that he is risking a twenty-year prison sentence. Sergeant Maylon Stark (George Reeves) has told Warden about Karen's many previous affairs at Fort Bliss, including with him. As their relationship develops, Warden asks Karen about her affairs to test her sincerity. Karen relates that Holmes has been unfaithful to her most of their marriage. She miscarried one night when Holmes returned home from seeing a hat-check girl, drunk and unable to call a doctor, resulting in her being unable to bear any more children. She then affirms her love for Warden.
Prewitt and Maggio spend their liberty at the New Congress Club, a gentlemen's club where Prewitt falls for Lorene (Donna Reed). She wants to marry a "proper" man with a "proper" job and live a "proper" life. Maggio and Staff Sergeant James R. Judson (Ernest Borgnine) nearly come to blows at the club over Judson's loud piano playing.
Later, Judson provokes Maggio by taking his photograph of his sister from him, kissing it, and whispering in Prewitt's ear. Maggio smashes a barstool over Judson's head. Judson pulls a switchblade, but Warden intervenes. Judson backs down but warns Maggio that sooner or later he will end up in the stockade, where Judson is in charge.
Karen tells Warden that if he became an officer, she could divorce Holmes and marry him. Warden reluctantly agrees to consider it. Warden gives Prewitt a weekend pass. He goes to see Lorene. Maggio then walks in drunk, having deserted his post. The military police arrest Maggio, and he is sentenced to six months in the stockade.
Then Sergeant Galovitch picks a fight with Prewitt. At first, Prewitt refuses to fight back and then resorts to only body blows. His fighting spirit reemerges, and Prewitt comes close to knocking Galovitch out before Holmes finally stops the fight. Galovitch accuses Prewitt of starting the fight, but the man in charge of the detail says that it was Galovitch. Holmes lets him off the hook.
The entire incident is witnessed by the base commander, who orders an investigation by the Inspector General. After Holmes' motives are revealed, the base commander orders a court-martial. When Holmes begs for an alternative, an aide suggests for Holmes to resign his commission. Holmes' replacement, Captain Ross (John Bryant), reprimands the others involved and has the boxing team's framed photographs and trophies removed. He then demotes Galovitch to private and puts him in charge of the latrine.
Maggio escapes from the stockade and dies in Prewitt's arms after telling of the abuse he suffered at Judson's hands. Prewitt tracks Judson down and kills him with the same switchblade Judson pulled on Maggio earlier, but sustains a serious stomach wound. Prewitt goes into hiding at Lorene's house.
When the Japanese attack Pearl Harbor, it catches military personnel by surprise. Prewitt attempts to rejoin his company under cover of darkness but is shot dead by a patrol guarding against possible saboteurs. Warden notes the irony of the boxing tournament being canceled because of the attack.
When Karen finds out that Warden did not apply for officer training, she realizes they have no future together. She returns to the mainland with her husband. Lorene and Karen meet on the ship. Lorene tells Karen that her fianc  was a bomber pilot who was heroically killed during the attack. Karen recognizes Prewitt's name but says nothing.
Output: How many months is Angelo Maggio sentenced to the stockade?