This paper investigates the secondary control problem of shipboard microgrids (SMGs) with a high percentage of new energy sources under general noise. Firstly, a polymorphic SMG model is constructed, which enables the software-defined functionality of the control strategy and allows heterogeneous distributed generators (DGs) in AC SMGs to exchange packets of different types. Secondly, due to the presence of highly dynamic and high-power loads in the SMGs, a containment-based distributed secondary control strategy is proposed to improve the flexibility of the DG voltage regulation. Then, considering the complexity and diversity of disturbances during ship navigation, general noise is introduced instead of white noise to describe various disturbances. Furthermore, based on the random differential equations (RDEs), the NOS stability of the proposed strategy is proved using Lyapunov theory, which proves the effectiveness of the containment-based distributed secondary control strategy under general noise. And, the containment error is obtained to prove that the voltage and frequency of the system converge to the convex hull spanned by the virtual leaders, ensuring the high quality of the power supply. Finally, the validity of the proposed containment-based strategy is verified by an AC SMG model with four DGs in three cases.