There were a lot of doctrines released by the US to contain communism. One of which is the Truman's Doctrine.It aimed at stopping the geopolitical spread of communism in Turkey and Greece. Historian James Oakes explained containment as -
"The federal government would surround the south with free states,
free territories, and free waters, building what they called a 'cordon
of freedom' around slavery, hemming it in until the system's own
internal weaknesses forced the slave states one by one to abandon
Also, policies like the Marshall plan were formulated to rebuild Europe after WW2 and to contain the spread of communism.
How would communism be contained by rebuilding Europe?
It was the US which was rebuilding Europe and America would look noble in the eyes of the Europeans and thus the Europeans would like to follow the policy of the Americans (Capitalism) and would discard the policy of the soviets (communism).
The Americans believed in the Domino Theory. It meant that if a country becomes a communist state, then the states nearby the communist state would also be influenced by the communist state and would adopt communism. It was not formally accepted but American President Dwight D. Eisenhower described this theory once. It was believed that this domino effect would justify American intervention around the globe.
Also, containment actually meant(in historical terms) to stop the spread of communism " without a Nuclear War". Containment actually worked properly. If there would not have been a policy of containment by the US we wouldn't have been able to see the world as it is now. We would have seen India, Thailand, Afghanistan and many other countries as either communist or under the present Russian government.