^^^ I'll just quote this instead of re-hashing it.
[X-POST]
...
So if I have a 1L beaker that contains 1L of air at standard temperature and pressure, and I place it in a vacuum chamber with a hard vacuum, the force of gravity will keep the air from rising up and escaping the beaker?
https://i.imgur.com/TEEUvAy.jpgIf you seal the top of the beaker, and take it up 20 miles, and take the sealed top off, the air will escape the beaker. Why? Because you have essentially placed the beaker into the vacuum chamber of space.
The gravitational effect on air, causes weight on air at the lower levels, from the weight of the air at the higher levels, so that lower-level air is pushed into the beaker. If there was more air in space, the atmosphere would be thicker, because there would be more air for gravity to suck out of space, and you would have to go up 30 miles. But with conditions of gravity, solar (energy) wind, general cosmic ray energy, etc., as they are, 20 miles will do it.
In other words, the air in the beaker at ground level, is pushed into it by the weight of the air above it. You can test this easily by checking out water pressure increase as you get deeper in the ocean. Works the same way in both cases, but because air is lighter, it takes much more air above it to notice the difference.