One of the most common reasons that pipes rattle is because of loose connections. The force of the water causes pipes to shift slightly. If the brackets and attachments used to hold the pipes on ceilings or against walls are loose, the pipes will bounce off of them and create clanging metal sounds. Tightening loose brackets should solve most of the noise problems.
Certain valves in pipe systems are designed to control water pressure and shut off water in certain areas to route the flow to where it is needed. If valves close suddenly, the water will hit the valve, and the pressure pushing it behind will have nowhere to go. This pressure will explode in a loud banging sound that can cause all nearby pipes to rattle for a short time. This effect is known as water hammer, and needs to be dealt with by a professional.
In order to solve water hammer problems, professionals attach a water arrester to the system. This is a cylinder with a piston attached to the pipes near the valves that are causing problems. These cylinders absorb the pressure of the water before it can create noise or do any damage.
Scale is a layer of minerals that can coat water tanks and nearby pipes as hard water is heated. Hard water is naturally mineral-rich, and the particles in it can become bonded to nearby metal surfaces. As a result, when pipes or tanks heat, the scale resists the heat expansion and the result is loud bangs, pops and cracks that can reverberate out into surrounding pipes.
Scale can be cleaned with powerful corrosive cleaners, but the easiest way to solve the problem is to replace the pipes or tank and install a water softener. This softener exchanges the mineral particles in the water with sodium ions, which will not bond to surfaces and will prevent the buildup of any scale.