The solution that worked best were unions that accepted this path was inevitable, and instead of insisting on setting fire to the ship, negotiated transition payments for soon-to-be unemployed longshoremen. Essentially phasing out their jobs, giving them time to find other jobs or what-have-you.
The worst outcomes were ports that refused to accept the inevitable and doomed not only their entire union, but often the entire port industry for their town. For example, New York refusing to play ball, giving rise to New Jersey as a replacement port.