The idea of smart corrosion inhibition is basis on either inhibitor consumption where it is needed or reducing harmful matrix interaction with it. In addition, applying corrosion inhibitor in a coating causes many problems such as loss of inhibition capability, coating degradation, or both. A useful technique to overcome this problem is applying of inert host systems of nanometer dimensions as nanocontainers, which is loaded by corrosion inhibitors. In the present study, mesoporous silica nanocontainers with and without inhibitor (fluoride) were dispersed in the Alkyd coatings to improve corrosion resistance of Mg metal. Then, corrosion behavior of these coatings was studied in comparison with Mg in the NaCl solution. Electrochemical tests showed that theses coatings could protect the surface from chloride solution. In addition, fluoride release from mesoporous silica nanocontainers causes MgF2 formation in the interface, as an inhibitive compound. Furthermore, the corrosion mechanism of Mg in the chloride media was attributed to the formation of MgH2 and Mg(OH)2.