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.