The six-year agreement is expected to increase traffic at Pacific ports, which had sagged because of the prospect of a walkout.