How do you get rid of fruit flies?
There are a number of techniques that people have come up with. One that's pretty effective is to put out a small bowl of vinegar and add a few drops of dish soap to it. I've found that the vinegar will lure some fruit flies, but not all. And all you need are a few to hang around and breed, restarting the colony.
The most effective technique I've found that works when there's a lot of flies is a bit of a manual effort, but it pays off. Find a tall glass and drop in bits of fruit into the bottom. Maybe 1" tall of fruit debris. Banana is an excellent lure, and so are strawberries. You leave out the glass on the counter for about a half hour. When you come back to it, you'll see flies inside and on the fruit. But there are some who camp-out on the rim. I don't know why they do this... maybe a lookout for danger. Who knows. Anyway, bring one hand up by the side where most are on the rim. Then quickly bring your hand down on the glass while using your other hand to support it. Usually a good many of the flies on the rim will flee "across" the glass and then get trapped by your hand. Another technique is to use plastic wrap with both hands and come down from above. The flies don't notice the plastic as easily as a human hand. Once covered, bring the glass over to the kitchen sink. Using a flexible faucet or a glass full of water, pour water into the trap glass from a slight opening. Be sure the opening stays small. Once the glass is about 3/4 full, take away the water and recover simultaneously. Now shake the glass vigorously. Do it a few times. The fruit flies will be stunned. They will still craw around trying to get out of the water, but they're partly disabled. Next, spray inside the glass with glass cleaner (ammonia based). This will kill them in a minute or two. Once they're vanquished, pour out the water (the flies usually come along with it), rinse the glass, place the bait back in it, and set the trap again.
Using this technique I've been able to vanquish a large colony of fruit flies within about 4 cycles. I really don't enjoy doing this, but they're pests and they reproduce so prolifically... it's not like you're going to make a dent on their existence in the world.
The best way to reduce fruit flies from proliferating to begin with is to use a very fine strainer lined with paper towels to hold the fruit, then cover over with fine breathable cloth. This keeps fruit flies from invading your bowl of fruit. Of course, many times they come in via purchased fruit, so you have to keep an eye out to see if any start appearing. After the 1st day of buying new fruit, if there are no fruit flies then you're generally good.