In container sea–rail combined transport, the railway yard in an automated container terminal (RYACT) is the link in the whole logistics transportation process, and its operation and scheduling efficiency directly affect the efficiency of logistics. To improve the equipment scheduling efficiency of an RYACT, this study examines the “RYACT–train” cooperative optimization problem in the mode of “unloading before loading” for train containers. A mixed-integer programming model with the objective of minimizing the maximum completion time of automated rail-mounted gantry crane (ARMG) tasks is established. An adaptive large neighborhood search (ALNS) algorithm and random search algorithm (RSA) are designed to solve the abovementioned problem, and the feasibility of the model and algorithm is verified by experiments. At the same time, the target value and calculation time of the model and algorithms are compared. The experimental results show that the model and the proposed algorithms are feasible and can effectively solve the “RYACT–train” cooperative optimization problem. The model only obtains the optimal solution of the “RYACT–train” cooperative scheduling problem with no more than 50 tasks within a limited time, and the ALNS algorithm can solve examples of various scales within a reasonable amount of time. The target value of the ALNS solution is smaller than that of the RSA solution.