It would really depend on the type of caterpillars you have. Monarchs, for example, you would break off the branch you found the caterpillar on and move it to an enclosure that has screen or mesh, instead of glass, but this is if you're planning to have multiple caterpillars. A smaller container is fine as long as there's ventilation, and a small number of caterpillars (1-2). You'd have to research the other things that they eat, but milkweed plants would be a good place to start. You would also need to have a sturdy branch that the caterpillars can make their chrysalis's on. You don't need to give them water because they get all of the water they need from the leaves that they eat. Again, what they eat and how long they cocoon for depends on the caterpillar, so I'd look it up based on the type of caterpillars you're going to get.