It’s amazing that the captain of such a large vehicle has through the results of their choices the capability to do so much harm
But if you were someone like Russia or Iran who wanted to financially hurt the US (or any other country - and, equally feasible for the CIA or Mossad or whomever to use it as tactic to financially harm any enemy country with a significant port; or a terrorist group wanting to kill people seems less likely but not impossible) - wouldn't you be having that same thought now?
Secret services of various countries surely wouldn't find it hard to plant agents in shipping companies who end up captaining huge container ships around the world if they wanted to, and there's probably enough low-security situations for the boat when docked that gaining physical access (through spies taking engineer jobs or through sneaking onboard at a quiet time) could maybe allow some sort of sabotage equivalent to partially cutting the break lines on a car, which could be planned to cause problems roughly the right number of minutes after a ship leaves port to have the highest chance of impact.
If your goal is hurting a country financially rather than murderously, and you want an illegal way to do it that's completely deniable and even looks accidental, I'm not sure how many better options there would be?
I hope I'm wrong and it wouldn't be as easy as I'm imagining for any major country to place someone they trust (but won't be linked to them / suspected) into a career leading to being a captain on these ships...
(It might not even be limited to state actors - it's not unprecedented for a business executive to be a psychopath willing to commit crimes to boost their business, what's to stop the CEO or owner of a port, or a toll bridge, or a construction company from bribing a ship's captain with $20M dollars to take a port or bridge out of action, even a brief closure could be worth enough money to alternative locations and/or companies hired to fix it to make such a huge amount more money that a huge bribe would still make it wildly profitable. Obviously most companies won't have people specialised in committing this type of crime, so it wouldn't be easy to find the right captain who'd accept a bribe for that, yet alone do it without getting caught, but the captain could maybe create a fake medical emergency to cover their "mistake", etc... hopefully it's such a big criminal risk, and hard enough to do, that there wont be any crossover between the hopefully low number of psychopaths in positions of major corporate power and people who could pull it off if they wanted to.)