GATESVILLE — Lark Goode, wearing a stark white prison jumpsuit, set a prosthetic leg down on the glazed concrete floor and calmly walked to the other side of the gymnasium. At her signal, Rocky, a black lab mix with a naturally bobbed tail, retrieved the leg and brought it to Goode.

Bounding dogs and puppies are not the first thing one thinks of when picturing prison, but they are a common sight at the Dr. Lane Murray Unit and the Christina Melton Crain Unit, two women’s prisons in Texas where 43 female inmates volunteer for Patriot PAWS, a nonprofit that trains service dogs for veterans with disabilities who live around the country.

Goode, 42, a former massage therapist, continued running through training exercises. On command, Rocky fetched a phone off a cabinet and went to get help when Goode pretended to faint.

Rocky will move to Bozeman, Mont., in April to live with Al Harmata, an eagle researcher at Montana State University who lost his left arm and leg when he was hit by a rocket-propelled grenade in the central highlands of Vietnam. Goode, the daughter of a Vietnam veteran, teared up as she watched Harmata bond with Rocky.

“This is the first time I’ve had the opportunity to feel like I’m doing something for someone other than myself,” said Goode, who was convicted of shooting a Plano man in the back of the head after a Valentine’s Day date in 2002.

Harmata, 68, is thrilled to be getting a dog to help him, as his mobility has been hampered in recent years by back and knee pain. “Getting up and doing something is a lot more painful than it ever used to be, and Rocky will help relieve that,” Harmata said.

Patriot PAWS was established in 2006 by Lori Stevens, a retired rural mail carrier who wanted to train dogs in order to help veterans live independently. Two years later, Christina Crain, then the chairwoman of the Texas Board of Criminal Justice, heard about the program and recommended it to the state prison system, thinking it would improve morale behind bars and cut down on recidivism.

Such alliances between prisons and dog training nonprofits date back to 1981, when Sister Pauline Quinn, a Dominican nun, founded a program in Washington State. (A dramatized version of Sister Quinn’s story was told in a 2001 TV movie, “Within These Walls,” starring Laura Dern and Ellen Burstyn.) Now, such programs can be found in penal institutions in more than 30 states.

Demand for service dogs, particularly among veterans returning from the wars in Iraq and Afghanistan, has far outstripped supply. Patriot PAWS has placed more than 70 dogs across the country and has 99 veterans on a waiting list. Dogs have proved particularly useful in managing post-traumatic stress disorder — they can even be trained to wake someone up from a bad dream.

Training a service dog takes from 18 months to two years and, even with inmate labor, can cost up to $20,000. Patriot PAWS, which has 10 staff members and 70 volunteers outside the prison, does not charge veterans for their dogs and relies entirely on donations. Interested inmates are screened by the warden and by Stevens, and those selected move in to one of the dorms dedicated to the program.

Breeders donate the puppies — mostly Labradors, golden retrievers and Labradoodles — and they are brought to prison after they have had their second round of immunizations, typically at 10 weeks. Behind those barbed-wire fences, inmates spend eight to 10 hours a day teaching the puppies more than 80 basic obedience commands. The dogs rotate among the inmates, staying with each for up to eight weeks, accompanying them to school and church and sleeping in wire crates beside their beds.

After four months, the dogs are taken by volunteers outside the prison, who work on more specialized commands and socialize them to interact with the larger world, including learning how to sit quietly in movie theaters and on airplanes. The dogs are then brought back to prison for final polishing.

Gatesville is home to a cluster of prisons, and three and a half miles down the road from the Lane Murray Unit’s gymnasium, 33 inmates piled into a large room in their dormitory in the Crain Unit and spoke reverently about how the program has shaped their time behind bars.

“My family tells me, ‘Only you could find dogs in prison,’ ” said Patricia Ball, 58, who left behind five dogs in San Antonio when she began her 15-year sentence for theft two years ago.

“These dogs serve a dual purpose — they’re good for us, and then they help our veterans,” Ball said.

Kathy Allen, 39, spent six years on the streets of Lubbock, estranged from her family, cooking methamphetamine. Now four years into her 15-year prison sentence, she recently moved into the Patriot PAWS dorm.

“My son’s in the Navy, and when my family found out that I’m in this program, they’re proud of me,” she said. “I did methamphetamines for 15 years and they consumed my life. And now my life has been consumed by this puppy.”