The obvious solution is to agree that any receiving containers from the ship owe an equitable sized fee based on their fraction of all the containers.
Also to charge creditors that 'arrest' a ship the mooring fee for the port (since they're the ones demanding it stays there).
The ship, any unclaimed cargo, and any unclaimed containers, would then be fire-sold with the base price of the remaining debt for that ship and the condition that whoever buys them is then responsible for them. Any additional proceeds go first to lessening the unload fees (presumably already paid for by the cargo's owners in their transit fees) and finally back to the former owner of the ship.
I forgot to add: The nation receiving the cargo should have an economic stability interest in backing the loans to do this, but those receiving cargo obviously also need to be in on the underwriting of these efforts.
Second edit: It also becomes obvious to me that the equilibrium price for 'when is it bad enough to execute this' is when those who need to claim the cargo from the ship value what they're getting enough to bail out the price of selling the vessels for scrap.
The one doing the sale isn't the company, it's the government overseeing the bankruptcy of the fragment they're handling (the vessel).
As for the input costs, they'd probably (and should) enforce the standard market rate of processing fee.
The idea isn't that the company is bidding on the value of their cargo; it's that the companies FIRST get to declare if they're writing off their cargo or paying whatever their split of the loading fee is (possibly a maximum value they'd claim at) and THEN anything left is sold off (to get rid of it).
Also to charge creditors that 'arrest' a ship the mooring fee for the port (since they're the ones demanding it stays there).
The ship, any unclaimed cargo, and any unclaimed containers, would then be fire-sold with the base price of the remaining debt for that ship and the condition that whoever buys them is then responsible for them. Any additional proceeds go first to lessening the unload fees (presumably already paid for by the cargo's owners in their transit fees) and finally back to the former owner of the ship.
I forgot to add: The nation receiving the cargo should have an economic stability interest in backing the loans to do this, but those receiving cargo obviously also need to be in on the underwriting of these efforts.
Second edit: It also becomes obvious to me that the equilibrium price for 'when is it bad enough to execute this' is when those who need to claim the cargo from the ship value what they're getting enough to bail out the price of selling the vessels for scrap.