The union representing 45,000 dock workers on the East and Gulf Coasts and their employers said they reached a tentative deal averting a strike.