It can't take all the gas out. What it does is reduce the amount of gas in there. It does it by using a piston to enlarge the combined volume of the container plus the pump barrel without admitting any extra gas. The pressure equalises by gas rushing out of the container into the barrel. As the piston returns to the closed position, a valve between the container and the piston barrel prevents air in the piston barrel from re-entering the container, and a valve in the piston barrel then makes the gas in the barrel go out to the atmosphere.
If the open barrel has the same volume as the container, then every time the piston is pulled out, the amount of gas in the container is halved.
So it is never possible to remove all the gas from the container. It can only asymptotically approach vacuum, and physical constraints set a limit on how closely it can approach.
When you get down to very low vacuum, the methods of reducing pressure further are a bit more like ' pushing'. The 'Getter' system, used in old CRTs uses a reactive metal pellet that's vaporised by RF heating. The vapour passes through the (already low) vacuum, at speed and sweeps (pushes) the few remaining molecules across the tube and they get stuck permanently on the inside of the glass envelope. A Diffusion Pump does a similar thing by passing a fine stream of Oil particles through the vacuum, which sweeps away most of -what's left from the conventional pump (again, pushing remaining rubbish away). None of the low pressure systems will work until a conventional pump (suction style) has reduced the pressure to a pretty low value