Now that I have my handy-dandy kitchen compost bin (which I love, by the way!) I find I occasionally get fruit flies in the house. Here is a cheap, easy way to get rid of the pesky fruit flies:
First, pick a container. You can use a small bowl or a pint jar. I prefer my old-fashioned looking fruit fly trap (pictured on the right); unlike a bowl, the contents don't spill out easily, and unlike a pint jar, it looks more attractive on the kitchen counter.
Then fill the container. Pour about a cup of apple cider vinegar into the bowl, jar, or trap. To this, add just a drop or two of dish soap (I use Dawn). The smell of the apple cider vinegar attracts fruit flies, and the dish soap sticks to the critters so they can't fly. They will drown in the mixture.
To prevent fruit flies in the first place, take out the compost (or garbage) more frequently. Fruit fly eggs lay in wait in many fruits; the longer the fruit scraps are in your kitchen, the more likely it is those eggs will hatch.
It's also helpful to thoroughly wash your kitchen bin once in a while. One reason I love my stainless steel kitchen compost bin is that I can pop it into the dishwasher without fear of it being damaged. If you have a fancier bin - like those made of porcelain - you'll have to hand wash it. You might also consider using quick-to-compost bin liners - though I have to admit I can't quite make myself spend money on these.
And if you're thinking, "Now I know I don't want a compost bin in my kitchen!" let me assure you that I only get fruit flies about once a year - and getting rid of them is a snap. Beautiful, free compost for my garden is well worth the tiny bit of time it takes me to deal with fruit flies!