We consider the dynamics in and near galaxy clusters. Gas, dark matter and galaxies are presently falling into the clusters between approximately 1 and 5 virial radii. At very large distances, beyond 10 virial radii, all matter follows the Hubble flow, and inside the virial radius the matter particles have on average zero radial velocity. The cosmological parameters are imprinted on the infall profile of the gas; however, no method exists which allows a measurement of it. We consider the results of two cosmological simulations (using the numerical codes ramses and gadget) and find that the gas and dark matter (DM) radial velocities are very similar. We derive the relevant dynamical equations, in particular the generalized hydrostatic equilibrium equation, including both the expansion of the Universe and the cosmological background. This generalized gas equation is the main new contribution of this paper. We combine these generalized equations with the results of the numerical simulations to estimate the contribution to the measured cluster masses from the radial velocity: inside the virial radius it is negligible, and inside two virial radii the effect is below 40 per cent, in agreement the earlier analyses for DM. We point out how the infall velocity in principle may be observable, by measuring the gas properties to distance of about two virial radii; however, this is practically not possible today.