• Novel ZIF decorated HA nanocontainer with stimulus responsiveness were developed. • Encapsulation of Phen in nanocontainer can be easily achieved by one-step method. • Localized corrosion can be timely and precisely located and reported. • Coating exhibits barrier, corrosion self-diagnosing and self-repairing traits. Polymeric coatings with long life, strong environmental adaptability and high durability are of great significance for practical applications. This work presents a facial strategy to construct a smart nanocomposite coating with excellent shielding, corrosion self-diagnosing and self-repairing functions by integrating nanocontainers into epoxy resin. The nanocontainers were synthesized through decorating the hydroxyapatite sheets with zeolitic imidazolate frameworks (HA-ZIF), which were employed to encapsulate corrosion probe (Phenanthroline, Phen). With the occurrence of localized corrosion, Phen molecules could be timely released and reacted with the metal ions to form conspicuous red color at damaged sites, achieving real time corrosion diagnosing function. Given the stimulus responsive property of ZIF, the corrosion propagating process can be significantly inhibited by the released benzimidazole. As contrast of the traditional nanocontainers applied in anticorrosion coating, the inhibitors were used directly to synthesis the HA-ZIF nanocontainer rather than subsequent loading, which greatly improved inhibitors content in nanocontainers. Moreover, the impermeability of composite coating has been remarkably enhanced by the presence of HA sheets, ensuring the long-term protective performance. Importantly, the integrating multi functions in one coating is realized in the ingeniously designed nanocontainers. It is envisioned that the facial and feasible strategy provides insights in improving the longevity, functionality and reliability of protective coatings.