Huntington Beach firefighters used a forklift and a harness system to pull the horse, named Rodeo, out of the metal container, FOX 11 of Los Angeles reported.
Passersby kept the horse calm until emergency crews arrived on scene, the report said.
Neither the horse nor the firefighters were injured, the Huntington Beach Fire Department said in a tweet.
Officials were called to rescue the horse shortly after 2:30 p.m., FOX 11 reported.
Rodeo had slipped out of his enclosure and stepped off of raised platform lined with dumpsters, witness Kra Brundage told KTLA-TV. The horse then stepped on top of the dumpster and fell in.
"To a horse’s eye, that looks solid," she said. "So he thought he was stepping onto something solid, and ended up falling into the trash can."