In container terminal, the container trucks should go by a “quay crane - container trucks -import and export block” routing, and the optimization of this routing has become the focus of this paper. This study divided the problem of routing optimization into two levels: one is a routing optimization model of single container truck which takes the lowest total cost as the target, without considering the distribution of overall transportation task; the other is a routing optimization model concerning the allocation of no-load trucks, aiming at the lowest cost of transportation task. We designed an improved Particle Swarm Optimization (PSO) algorithm to solve the two-level optimization model, and the influence of emission policy on the two-level optimization model and the influence of the number of container trucks on the transportation distance of level II in optimization model are analyzed. The results show that the increase of carbon tax will lead to the decrease of emissions in level I, but has no effect on the emissions in level II. The increase in the number of container trucks will lead to a reduction of the no-load transportation distance in level II.