There are several DIY methods of catching/killing fruit flies that are claimed to work, and one of the most common is with the use of apple cider vinegar.
The basic trap is simply to place about 1/2 cup of apple cider vinegar in your mason jar, and add 1-3 drops of dish soap. This alone should be enough to begin capturing fruit flies.
Some instructions call for a slightly more advanced setup, where you use a paper funnel. Another tweak you can make to the method is to place a piece of rotting or overripe fruit into the apple cider vinegar.