MobCages mod adds cages which can be used to hold animals, for both transport and storage. Only passive animals can be captured, no hostile mobs.
Recipes:
To cage an animal, right click on it with a Cage in your hand. To free an animal, right-click on the cage with a Crowbar.