Does a rigid box of gas cool over cosmological timescales? According to standard cosmology theory the physical momentum $p$ of both massive and massless particles decay like:
$$p \propto \frac{1}{a(t)}$$
where $a(t)$ is the scale factor as function of cosmological time $t$ (for a derivation see page 12 in these cosmology lecture notes).
Does this imply that a gas inside a rigid box cools over cosmological timescales?
In other words does the space enclosed by the box expand through its walls even though they are rigid?
We know that the walls of the box constrain the gas particles to stay inside the box; but surely they do not constrain the expanding space itself though which the particles move?
 A: The binding  of matter with the four forces, gravitational, weak, electromagnetic, strong is much stronger than the expansion of the universe, the famous raisin bread analogy.


Animation of an expanding raisin bread model. As the bread doubles in width (depth and length), the distances between raisins also double.
The loaf (space) expands as a whole, but the raisins (gravitationally bound objects) do not expand; they merely grow farther away from each other.

Your box is one of the raisins. It is held together by strong electromagnetic forces Its dimensions are held constant by these forces  whether there is gas inside or not. In addition , the walls are a boundary for  the gas starting with  its initial temperature and pressure again through electromagnetic forces. ( the gas will cool due to black body radiation but that is another story).
The whole raisin is held together by the standard forces, only the space between raisins is affected by the expansion. It might help you to think quantum mechanically: Quantum mechanically there is no empty space where a gas exists with temperature and pressure. There are a great number of fields of operators  of elementary particles, with creation and annihilation happening continuously to keep the gas at that temperature and pressure.
