A longer turnaround time of container trucks in ports are commonly related to a higher energy cost and more carbon emissions, hindering the green development goal of ports. In this context, the implementation of Truck appointment system (TAS) is widely recognized as a very effective way to reduce external container trucks’ total turnaround time in ports. However, the number of appointment quotas allocated for each time window are the key to determine the efficiency of a TAS. This study proposed a data-driven approach to address the appointment quota optimization problem, which combined data mining technologies with mathematical optimization modeling methods, and an empirical study in YT port, China was given. Specifically, the smart gate data of the port were mined to explore the causal relationship between the number of truck arrivals at each time window and their total turnaround time within the port. The results exhibited a non-deterministic quadratic function relationship, and the range of changes regarding total turnaround time were measured by boundary functions obtained through a stepwise approaching algorithm. Considering the obtained causal relationship and its uncertainties, a robust optimization model was built to find the optimal appointment quota plan by minimizing the total turnaround time of external container trucks and the total deviations from the trucks’ preferred arrival time in the worst case. A numerical experiment was designed to examine the validity of the proposed data-driven approach, and compare the effectiveness of the proposed approach with a conventional stochastic optimization method. The results indicated the proposed approach was more effective on reducing the external container trucks’ total turnaround time in ports under a Truck appointment system.