All materials are subject to thermal expansion, but metals are particularly prone to changes in length in response to temperature fluctuations. In crude oil pipelines it is desirable to have the pipe and its contents warm, as this keeps the oil flowing well, but changes in length must be carefully controlled or the pipe will rupture and become an environmental disaster.
There are two main methods for handling temperature-induced length changes in pipelines. One method, which was used on the Trans-Alaska pipeline, is to install an S-shaped curve in the pipe at regular intervals. This part of the pipe is usually laid on supports that let it slide a bit, so changes in length can occur.
The other method is to install mechanical expansion compensators at intervals. These come in a variety of configurations, but all include a bellows or other sliding mechanism or a flexible section that will accommodate length changes without leaking. Companies like Kompenze design and build these devices to order for large pipeline projects; their website contains diagrams and pictures that show how the different devices work.