Deadly infection outbreaks in confined spaces, whether it is a COVID-19 outbreak on a cruise ship or at a veteran home, or measles and stomach flu outbreaks in schools, can be characterized by their rapid spread due to the abundance of common spaces, shared airways, and high population density. Preventing future infectious outbreaks and developing efficient mitigation protocols can benefit from advanced computational modeling approaches. Here, we developed an agent-based modeling approach to study the spatiotemporal dynamics of an infection outbreak in a confined environment caused by a specific pathogen and to determine effective infection containment protocols. The approach integrates the 3D geographic information system of a confined environment, the behavior of the hosts, key biological parameters about the pathogen obtained from the experimental data, and the general mechanics of host-pathogen and pathogen-fomite interactions. To assess our approach, we applied it to the historical data of infectious outbreak caused by norovirus, H1N1 influenza A, and SARS-CoV-2 viruses. As a result our model was able to accurately predict the number of infections per day, correctly identify the day when the CDC vessel sanitation protocol would be triggered, single out key biological parameters affecting the infection spread, and propose important changes to existing containment protocols, specific for different pathogens. This research not only contributes to our understanding of infection spread and containment in cruise ships but also offers insights applicable to other similar confined settings, such as nursing homes, schools, and hospitals. By providing a robust framework for real-time outbreak modeling, this study proposes new, more effective containment protocols and enhances our preparedness for managing infectious diseases and emerging pathogens in confined environments.