We consider the linear stability of an isothermal, pressure-bounded, self-gravitating gas slab. Such a configuration is unstable at sufficiently long wavelengths and grows at rate approximately square-root G-rho, where rho is the density of the gas slab, but at high external pressure the nature of this instability is quite different from that of the usual Jeans instability. We develop an analytical model that reproduces the behaviour of the instability found numerically by Elmegreen & Elmegreen. They found, surprisingly, that the critical wavenumber for the onset of the instability is always of the order of the layer thickness, independently of the level of self-gravity and the external pressure. For high external pressure, the instability is due to a neutral mode that exists because external pressure can hold the layer, which attains nearly constant density and pressure, to any distorted shape. In this case, the unstable mode is neither a p-mode nor a g-mode, and has a curl-free and divergence-free velocity field. In the linear regime, the main effect of the instability is to distort the shape of the layer, with very little gas compression. One application of this analysis is to the stability of the shocked gas layer that results from the supersonic head-on collision of identical clouds. We conclude that dynamical instabilities within the shocked layer do not substantially enhance star formation when the layer is (ram) pressure-confined.