Flies are typically kept in plastic or glass containers. I strongly recommend disposable plastic cups. Glass containers seem to suffer from condensation to a much greater extent. This can prevent the media from adhering to the vial (allowing it to slip when the vial is inverted). Recycling is something that we should all aim for, however fruit fly vials get SO 'baked-on' that it is very difficult (and energy inefficient) to clean them effectively.
Vials can be sealed with sponge (difficult to cut perfectly, but good at keeping out mites), cotton wool (cheap, easy, but only good for vials with small openings. Not reuseable.), filter paper (can be damaged when wet) or netting (cheap, reuseable, can allow mites and interbreeding with wild flies). If you use netting, it is best to keep the flies in a cabinet to keep out other flies.
Handling fruit flies?
Under laboratory conditions flies are anaethetised with CO2 or ether. This renders them unconcious for a few minutes without damage. If you have a cylinder of CO2 for a planted aquarium, try inverting the vial, and introducing a gentle flow of CO2. After just a few seconds the flies will fall unconcious. Luckily flightless flies are relatively easy to manipulate without CO2, but if you have difficulties, 5-8 minutes in a freezer greatly reduces their mobility. But work quickly, because they will wake up soon!
Always use funnels when moving flies from one vial to another. This will largely prevent escape, and allows a vial to be left 'unlidded' with flies still in it. If any do start to walk back up, a gentle tap soon sends them back!