The air compressor on the diesel engine is driven by the operation of the diesel engine, usually driven by a belt or gear.
The compressor is actually a single-cylinder internal combustion engine, except that it does not output power externally. Natural air enters the cylinder from the filter element through the valve, and then enters the air storage tank from the cylinder through the exhaust valve.
This is how the compressor works continuously to produce compressed gas. The up and down movement of the piston is completed by the diesel engine driving the compressor crankshaft. When the air pressure reaches the specified pressure, the pressure limiting valve will open and no more air will enter.