A.P. Moller-Maersk has agreed to buy German rival container shipping line Hamburg Süd, sending shares in the Danish shipping company up nearly 5 percent.

The deal highlights a push to toward consolidation the container shipping industry, which has been grappling with low freight rates and oversupply.