Containment was the idea of George F. Kennan, a diplomat who worked in the US Embassy in the Soviet Union for 20 years. He suggested in what is known as "The Long Telegram" to Truman that containment was the way to deal with the Soviets. That is, do not directly threaten them or try to roll back communism where it already existed, but contain the spread of it and be willing to fight to stop the spread, or aid our non-communist allies to stop it for us.
I like to compare it to the Free Soil Party of the 1840s US. They did not seek to abolish slavery, only to stop it from spreading west.
One of the parts of containment that hasn't already been mentioned was the semi-implicit idea that we would also be competing with the Soviet Union in an economic sense. There was some understanding, particularly later in the Cold War, that the drive to constantly outgun the other side would lead to enormous expenditures on military hardware and research which the US could handle more easily than the Soviet Union given our more dynamic and robust economy.
The article referenced below suggests a viewpoint not often hear publicly but one that suggested the entire cold war could have been avoided along with its accompanying expense and massive nuclear build up. The utter destruction of nearly all of Europe's economies during and following the war suggested an alternative policy that mimicked in some ways the actual way that the Cold War was won which many would argue was eventually an economic victory brought about by the constant pressure on the Soviet Union to keep up with the West in terms of military hardware.
During the time that the United States was pursuing this policy, it did a whole bunch different kinds of things to try to contain communism and prevent it from spreading farther than it already had.
It gave economic aid to countries to prevent them from wanting to become communist. The biggest example of this is the Marshall Plan.
It engaged in covert action to try to overthrow government it thought were communist. Examples of this are when we helped overthrow the governments of Iran and Guatemala in 1953.
It engaged in actual wars like those in Vietnam and Korea.