Ports are of great significance in processing cargo containers and facilitating global marine logistics. Nevertheless, the susceptibility of the container shipping network for hazardous cargo is likely to intensify in the event of a significant disruption at a major port, such as adverse weather conditions, inadequate management practices, or unforeseen catastrophes. Such situations require the deployment of port protection emergency response and prevention in advance. This study proposes a digital twin (DT) model that employs extensive and trajectory data within containers to comprehensively analyze the occurrence of hazardous cargo failures within the port storage process. The virtual models of physical entities in the port are created through a data-driven approach, and the behavior of these entities in a port environment with big data is then simulated. A combination of a convolutional neural network (CNN) and a long short-term memory (LSTM) algorithm is employed to provide predictions for the service layer of the DT system. The predicted correlation coefficients of temperature and humidity in the container reach 0.9855 and 0.9181, respectively. The developed system driven by DT models integrated with a CNN and the LSTM algorithm can more effectively assist the safety manager in achieving prevention in port operations. This study enables marine authorities and decision-makers to optimize emergency procedures, thereby reducing the probability of accidents in port operations and logistics.