“First Man” is the best kind of movie. It shows us that real strength comes not from winning but from failing — and that our lives will be judged not by our triumphs but by how we pick ourselves up after tragedy.

That might sound preachy, but “First Man,” which takes us inside Neil Armstrong’s journey to becoming the first man to walk on the moon, puts a human face on NASA and its efforts to beat the Soviets in space. And in doing so, it shows how crazy and dangerous the historic Apollo 11 flight really was.

Damien Chazelle, who gave us the Oscar-winning “La La Land” and “Whiplash,” reteams with Ryan Gosling, as Armstrong, and takes us inside the space program and the creaky module that somehow makes it to the lunar surface.

As a viewer, you’ll see how cramped and rickety the space capsules were, and you’ll hear the moaning of metal under pressure. You’ll also marvel at how primitive the lunar technology was —and how it was a miracle that NASA actually pulled off the Apollo 11 mission.

But “First Man,” as thrilling as it is, never forgets its heart. Chazelle and screenwriter Josh Singer show the private side of Armstrong’s life —a story that hinges on the events between the moon and the kitchen sink. The latter part of that equation is anchored by Claire Foy as Janet Armstrong, who is bound to get a supporting actress Oscar nomination for a scene in which she insists that her husband sit down at the kitchen table and explain to his two young sons that he might never be coming home again. It’s a remarkable moment in a movie filled with joy and sorrow.

As Armstrong, Gosling takes a quietly ferocious approach to his character, much like the astronaut was in real life. Through Gosling’s portrayal, we see that Armstrong has suffered a great family loss. And he has watched friends and fellow astronauts perish. But he persists. He believes that he is going to make it to the moon. And he does everything he can to make that happen on July 20, 1969.

The approach to the lunar surface turns out to be far riskier and problematic than it seemed at the time as millions around the world watched on TV. We’re inside the capsule with Armstrong and Buzz Aldrin (Corey Stoll) as crude alarms sound about running out of fuel and as the folks back at Mission Control wonder whether they’re facing failure.

What’s striking about “First Man” is that it delves into NASA’s low points, especially the 1967 destruction of the Apollo Command Module in a pre-flight test for Apollo 1 at Cape Canaveral, which killed Edward H. White II (Jason Clarke), Virgil “Gus” Grissom (Shea Whigham) and Roger B. Chaffee (Cory Michael Smith).

“First Man” also deals with the scary-crazy Gemini VIII mission, in which Armstrong and David Scott (Christopher Abbott) link their spacecraft with another one while in Earth orbit. Space historians will remember what happened after the docking: the start of uncontrollable spinning. Watching Armstrong figure out how to get out of the disastrous situation is a marvel.

As with “Whiplash,” Chazelle and his team are exploring what he calls the messiness of mastery. And as space experts know, NASA had a lot of messiness on its way to the moon.

The movie is based on the 2005 biography of the same name by James R. Hansen, who approached Armstrong and secured his cooperation with the writing of the book. The astronaut also signed off on the movie adaptation before his death on Aug. 25, 2012.

Armstrong’s sons, Mark and Rick, have been attending festival and pre-release screenings of “First Man” and singing its praises, saying that the movie accurately captures their father’s personality and determination.

As “First Man” hits theaters this week, it seems poised to get a load of Oscar nominations, from directing to acting to the technical awards.

Production designer Nathan Crowley deserves a nomination for accurately portraying the spacecrafts as “tin cans being fired up.” Linus Sandgren, as director of photography, captures the eeriness of the lunar surface with perfection. For the more intimate scenes inside the Apollo spacecraft, Sandgren shoots on 16 mm film. But once the astronauts step out of their craft, there’s a visceral switch to IMAX — an immersive and awe-inspiring change.

If you get the chance, see “First Man” in an IMAX theater. It screened for critics at the recent Toronto International Film Festival at the Cinesphere, the world’s first permanent IMAX theater.

As you’ll see, “First Man” is a giant achievement — and full of glorious determination.