what you propose is capturing the waste heat given off by the cooling fins on the outside of an air compressor's cylinders while the compressor is running. This is certainly feasible, but note the following:
We take the example of a Dayton two-cylinder air compressor driven with a 1 HP electric motor, working into a tank rated for an operating pressure of 120 PSI (I know this unit well).
It requires about one minute to run the tank up to 120 PSI. At the end of this cycle, the pump shuts down and if you put your hand on the cooling fins, they will feel quite warm but not hot enough to burn your fingers- certainly not warm enough to boil water.
Now if you had a water jacket surrounding the cylinders you could certainly use the compressor heat to preheat the water flowing into a conventional water heater and recoup those losses- but the money saved will be just a small fraction of the operating cost of the water heater without the preheat.