Used to take scrap lumber and drill a row of holes, glue on a cap over the holes and rip it about 3/4 the way up. Pretty handy for AAs, AAAs and CR123s. A bit bulky but still good for Cs. Less good for Ds.

Ten AAs fit in a 10" length of 5/4. They keep the batteries entirely separate and well protected. Once made you can screw the unit to any vertical surface, I used to have a set screwed to the inside of my truck box, and they can also be used as carriers.

You can rig a latch or simply wrap a bit of inner tube around the units to keep the top on. Mounted vertically the tops stay put as long as there are a couple of batteries inside.