A device for compressing coolants has the piston compressor of cooling installations replaced by a liquid piston that consists of magneto- fluid (1) and is driven by a magnetic field. The magnetic field is generated by a solenoid (2) and a permanent magnet (4). The magneto-fluid is changed in position by the magnetic field, and also in its shape, thereby adopting a valve function.