Vinegar & fruit in a covered glass
Combining some of the Answers, in a quick and easy solution:
Grab one or more drinking glasses.
Drop a piece of fruit into some water, add some vinegar if handy.
Stretch taut a piece of Saran Wrap-style plastic over the glass. If not tight, wrap a rubber band around.
Poke two or three tiny holes with the tip of a knife. Very small holes. The fruit flies slip through the tiniest of spaces, kind of amazing.
The idea is for them to slip into the glass, drawn by the delicious-smelling rotten fruit aroma, but render them unlikely to find their way out.