Background: Container terminals (CTs) have constantly administered truck appointment systems (TASs) to effectively accomplish the planning and scheduling of drayage operations. However, since the operations in the gate and yard area of a CT are stochastic, there is a need to incorporate uncertainty during the development and execution of appointment schedules. Further, the situation is complicated by disruptions in the arrival of external trucks (ETs) during transport, which results in congestion at the port due to unbalanced arrivals. In the wake of Industry 4.0, simulation can be used to test and investigate the present CT configurations for possible improvements. Methods: This paper presents a simulation optimization (SO) and simulation-based optimization (SBO) iteration framework which adopts a dual transactions approach to minimize the gate operation costs and establish the relationship between productivity and service time while considering congestion in the yard area. It integrates the use of both the developed discrete event simulation (DES) and a mixed integer programming (MIP) model from the literature to iteratively generate an improved schedule. The key performance indicators considered include the truck turnaround time (TTT) and the average time the trucks spend at each yard block (YB). The proposed approach was verified using input parameters from the literature. Results: The findings from the SO experiments indicate that, at most, two gates were required to be opened at each time window (TW), yielding an average minimum operating cost of USD 335.31. Meanwhile, results from the SBO iteration experiment indicate an inverse relationship between productivity factor (PF) values and yard crane (YC) service time. Conclusions: Overall, the findings provided an informed understanding of the need for dynamic scheduling of available resources in the yard to cut down on the gate operating costs. Further, the presented two methodologies can be incorporated with Industry 4.0 technologies to design digital twins for use in conventional CT by planners at an operational level as a decision-support tool.