In old pictures there are always dozens of smaller and bigger ships in the docks with hundreds of longshoremen working. Now many docks have closed and there are hardly any freight ships on once busy rivers like the the Danube or Thames.
Sorry if the answer to this question is obvious, I'm coming from a landlocked country :)
The main reason is simply that the ships have gotten bigger. Shipping has moved from smaller tramp steamers to massive container ships and supertankers. These can no longer travel down the rivers to the major cities, but instead have to use purpose-built docks in the estuaries. For example, London's main docks have moved from the Docklands of East London, to the town of Tilbury in Essex. In addition, the increased amount of cargo being shipped requires a lot of land-based infrastructure - additional rail links and roads. It can be difficult to build these in the centre of a major city, and so incentivises moving the ports outside the city.