A tentative agreement on a new five-year contract has been signed for some 20,000 dockworkers at 29 US West Coast ports, ending nine months of discussions.