Single-atom confinement inside carbon nanotubes has attracted much attention in many fields. This class of materials may not only serve as a catalyst but also as a support material for certain reactions. In this paper, we have studied the single-walled carbon nanotubes (SWCNT), single vacancy defect (SV) and Stone-Wales defect (SW) carbon nanotubes with Fe, Co and Ni atom by both inside and outside adsorption structures in density function theory (DFT). Our results reveal that the binding abilities of atomic Fe, Co, Ni onto the internal and external surfaces of the SWCNT, SV and SW are in following orders by metals: Ni>Co>Fe. The adsorption energies of SV toward Fe, Co and Ni are more stable than those of SWCNT and SW, which can be attributed to the three active carbon sites created by a C atom removing, while the SWCNT and SW demonstrate similar adsorption energy due to the similar structure. Generally, the stability of external adsorption structures is stronger than those of internal adsorption structures, but as for the SW, the stability of internal and external adsorption structures is close, which means that the defects have improved the confinement of carbon nanotubes to M (M=Fe, Co Ni).