This is actually a pretty interesting question.
For starters, it depends on the system you are analyzing. Atmospheric gasses are basically an open system that stays together due to the force of gravity. All the gas further down is supporting the weight of the above gasses. The force of this weight on top pressurizes all the air based on how much mass is above it. See for example John Rennie's linked possible duplicate to explain how it works on a macroscopic level.
In a closed container, we often don't consider the weight of the gas because the effects of the weight are minimal if the height of the container is not very large. In a very tall container, the pressure would also be affected by the weight. The gas on the bottom would have noticeably higher pressure than the gas above, because the gas on the bottom has to support all the weight of the gas above it.
The existence of the container isn't important, what is important is how tall the container is. If it is tall enough, than the weight of the gas will have a noticeable effect on the pressure distribution. Technically any closed container in gravity will have this; but unless the container is very tall the difference is negligible.