Approximately 20% of global container transportation activities are used for empty container repositioning, which does not generate profit margins. For container supply ports, in addition to periodically transporting excess empty containers to container shortage ports to reduce their inventory costs and meet empty container demand of container shortage ports, they also need to maintain a certain amount of empty container inventory to meet their uncertain needs in the future. This paper considers the container supply port and container shortage port as a whole, so that the container supply port maintains a certain amount of empty container inventory to meet its own uncertain needs, and empty container repositioning is carried out based on this. Based on queuing theory, an empty container repositioning model was established with the objective function of minimizing the total cost of the empty container inventory system and the empty container repositioning system and designing genetic algorithms to solve the model. The results indicate that considering empty container inventory and repositioning as a whole resulted in a total cost reduction of approximately 7.2%. Finally, a sensitivity analysis was conducted by changing the parameters in the model, and the results of the sensitivity analysis provided support for the decision-making of shipping lines in different situations.