Aleister, a terrier rescued from a California animal shelter, stars in 'Seeking a Friend for the End of the World,' along with several other rescue dogs.

The canine star of a movie about getting a last chance at love is a dog that got a second chance at life when he was rescued from an animal shelter.

Aleister, a 5-year-old terrier mix that was found in a California shelter in 2008, stars alongside Steve Carell and Keira Knightley in “Seeking a Friend for the End of the World.” The movie follows Carell’s character, Dodge, as he and Penny, played by Knightley, search for his high school sweetheart in the days before Earth is destroyed by an asteroid.

Aleister plays Sorry, a dog Dodge finds attached to his leg after a failed suicide attempt. A note by the dog simply reads “Sorry,” and Dodge takes it literally, addressing the dog as Sorry.

“Sorry enters the story right when Dodge has reached his lowest low and given up hope altogether,” said writer and director Lorene Scafaria in a press release. “He wakes up that morning and finds he has been given someone else’s burden, which becomes a responsibility that gives Dodge’s life meaning again.

“When I saw Aleister and his wonderful scrappy snaggletooth and wiry coat, I loved him and felt, ‘Here’s our hero dog,’” she said.

But Aleister wasn’t the only rescue dog on set.

"These days when a dog has a starring role, having two to three matching dogs is required. I searched all the shelters online to find a double for Aleister, and I finally found a good double but he wasn't available to adopt for another week," said dog trainer Sarah Clifford.

"A week into our training, I called to shelter to check on this dog and find out that they had messed up the dates in the computer system and had scheduled to euthanize the dog that same morning. He was already in the back room when I called. I was so sad to think this wonderful little dog would not be here anymore if I had not had the strange instict to call the shelter that morning to check up on him. So I named the double Mulligan, the do-over dog."

Mulligan learned the ropes quickly and was doing takes only two weeks after he was rescued from the shelter. Clifford says he did the scene where Sorry is crawling down the fire escape, as well as other scenes that required a lot of action.

In addition to Aleister and Mulligan, two other shelter dogs were also involved in the film.

“There was another terrier on-set, a fourth Sorry,” said Scafaria. “They just make the set better. Or maybe I’m a crazy-dog-lady-in-the-making.”

Aleister won the hearts of his co-stars early on, and he was particularly fond of Knightley, according to Clifford. When they met, “he went up to her and nestled on her dress,” she said.

But it was the dog’s on-screen interaction with Steve Carell that was most important to the movie.

“We would take a little bit of time every day before we started filming for what we called a bonding session. We’d get Steve and Aleister comfortable together. Steve gave him treats, and kissed and cuddled him. That way, when Aleister worked with Steve on camera, there was already a bond,” Clifford said.

Although “Seeking a Friend for the End of the World” is Aleister’s first major movie role, his previous credits include print and television commercials for Pedigree, Texas Energy and Microsoft. When he isn’t on set, the rescue pup spends his days sunning himself and sleeping upside down on the couch at a movie animals’ ranch in Castaic, Calif.

Just how often do shelter dogs end up in movies? More often than you'd think, according to Clifford.

"We almost always utilize the animal shelters to find dogs for film and television. The shelters and rescues are full of future stars! I would say that the majority — at least 80 percent — of all studio dogs come from shelters," she said.

And those doggy doubles that don't stay in show business aren't returned to the shelter.

"After the film I placed Mulligan in a home with a close friend of mine who is a Hollywood makeup artist. Now he lives as a spoiled pet," Clifford said.

“Seeking a Friend for the End of the World” arrives in theaters June 22. You can watch the movie trailer below.