It seems not to take much, but the primer compound, unlike the propellant powder, is a high explosive. It is only because there is so little of it that the force can be contained. If, somehow, primer compound were loaded into the cartridge case, it would take only a few grains to blow the rifle apart.
The actual firing progression is usually not recognized. When the firing pin hits the primer, it first drives the primer and case forward to the extent it can, depending on the amount of headspace. Then the primer, driven by the force of the exploding primer compound, backs out of the case as far as the headspace will allow.
Then the powder charge ignites, and presses the thinner forward case walls against the chamber walls. The neck is expanded and the bullet floats on gas as it is driven into the leade of the barrel.
Meanwhile, the head (rear) of the case is backing up under pressure as far as headspace will allow, backing over the primer. Since the front end of the case is pressed against the chamber wall, the rearward movement will stretch the case, again as much as the headspace allows.
The propellant gas pressure coming back through the flash hole pushes the primer back around the firing pin. This is why a misfired primer has only a shallow indent, while a fired primer appears to have a very deep indent. If the pressure is sufficient, it will cause the primer to expand into the beveled area around it, causing the flattened primers we associate with high pressure.
When the bullet leaves the muzzle and pressure drops, the elasticity of the case causes it to spring back from the chamber walls. It can then be extracted. If, in an automatic or autoloading firearm, the breech opens before the pressure drops, the case head can be torn off the case, since the front end of the case is still pressed against the chamber wall.
The required elasticity is found in only a few metals cheap enough to be used for cartridge cases, and the best is brass, which is why cases made of other materials have not been widely used in recent times except under special conditions.
Jim