This automation is inevitable. The ports are a choke point created by unnatural monopoly and a labor union is the incorrect solution. Particularly because their labor actions have massive collateral damage to other labor interests.
I believe that if trucking were properly unionized the port unions would be crushed. They're not that powerful they've just outlived this particular modernization the longest out of their former contemporaries.
Solving the problem might not be as easy as you suggest as long as their are powerful unions involved