New Panamax ships can carry 13,000 twenty-foot-equivalent units. 13,000 * 20 ft = 260,000 ft = 49 miles. (You can stack containers on top of each other, so 25 miles. There also needs to be space between the containers on a train for the couplers, etc., though, so a real train would probably be longer than this.)
I am not sure how much the railway helps. There is already a railway across North America and it's still cheaper to go via Panama at this scale.