Metering device for a machine for filling containers with a product, comprising: - a cylinder body defining a metering chamber, intended to be filled with the product, - a piston (10; 110) inside said metering chamber and separating said metering chamber into a supply compartment and a metering compartment, with the piston comprising a passage (12; 112) that communicates between the supply compartment and the metering compartment in such a way as to allow the passage of the product from one compartment to the other, - a valve (20; 120) for closing this passage (12; 112), - movement means (30; 230; 330) of the valve or movement means (230; 330) of the piston along the length of the cylinder body, in which said valve comprises drive means (21, 22; 121, 122) arranged on either side of the piston in such a way that the movement respectively of the valve or of the piston along the length of the cylinder body in a discharge direction drives the movement respectively of the piston or of the valve in said discharge direction and the movement respectively of the valve or of the piston along the length of the cylinder body in a transfer direction opposite the discharge direction, drives the movement respectively of the piston or of the valve in said transfer direction, and characterized in that: - the valve (20; 120) comprises a magnetic material, and wherein said movement means (230; 330) of the valve comprise means for varying a magnetic field (234, 232a, 232b, 233; 334) arranged in such a way as to drive the movement of the magnet by variation in the magnetic field along the length of the cylinder body in such a way as to drive the movement of the valve, or - the piston (10; 110) comprises a magnetic material, means for generating (234, 232a, 232b, 233) a variation in a magnetic field along the length of the cylinder body driving the movement of the piston, which drives the movement of the valve (20; 120) via said drive means (21, 22; 121, 122), the cylinder body being devoid of any actuating rod, and therefore also of an orifice passed through by such a rod. - a cylinder body defining a metering chamber, intended to be filled with the product, - a piston (10; 110) inside said metering chamber and separating said metering chamber into a supply compartment and a metering compartment, with the piston comprising a passage (12; 112) that communicates between the supply compartment and the metering compartment in such a way as to allow the passage of the product from one compartment to the other, - a valve (20; 120) for closing this passage (12; 112), - movement means (30; 230; 330) of the valve or movement means (230; 330) of the piston along the length of the cylinder body, - the valve (20; 120) comprises a magnetic material, and wherein said movement means (230; 330) of the valve comprise means for varying a magnetic field (234, 232a, 232b, 233; 334) arranged in such a way as to drive the movement of the magnet by variation in the magnetic field along the length of the cylinder body in such a way as to drive the movement of the valve, or - the piston (10; 110) comprises a magnetic material, means for generating (234, 232a, 232b, 233) a variation in a magnetic field along the length of the cylinder body driving the movement of the piston, which drives the movement of the valve (20; 120) via said drive means (21, 22; 121, 122),