For 1000 containers of the 40 foot class (which are more widespread than the standard 20 foot class, the train would have to be about 14.5 km long. If you take 1/2 m distance between the wagons.
" The Australian BHP Iron Ore is the longest train ever recorded in history at approximately 4.6 miles (7.353 km). In the Pilbara region of Western Australia, BHP owns and runs the Mount Newman railway. This is a private rail network designed to transport iron ore "
"Invented in the United States in 1984, it is now being used for nearly seventy percent of United States intermodal shipments. Using double stack technology, a freight train of a given length can carry roughly twice as many containers, sharply reducing transport costs per container."
https://en.wikipedia.org/wiki/Double-stack_rail_transport
But generally going around the southern tip of South America could well be cheaper--although it may take longer.