The US used numerous methods of containing communism in the 1940s, including economic, military, and political, which were generally successful. Communism did not spread to Western Europe with the use of these methods , but the US was not able to prevent the Soviet takeover of Eastern Europe in by the late 1940s. Though no country fell to communism under the Marshall Plan, and the US prevented communist takeover of Berlin in the Berlin Crisis, these events are only in relation to Western Europe.
Economically, the US made use of the Marshall Plan, ratified in 1947, to provide aid to European countries. The conditions made it impossible for the communist countries of Eastern Europe to apply for aid without making a fundamental change to their system of government. It included opening a country's economic records and opening the economy to US interests, which the Soviet Union refused to do.
The Marshall Plan led to the formation of Cominform in 1947, the Communist Information Bureau;, a way to coordinate the economies of the communist countries in Eastern Europe. However, the plan was effective in its $17 billion of US aid - no country that received aid fell to communism; in this sense communism from the rest of Europe was indeed "contained". It did not have an effect on Eastern European Countries under Soviet control, though, as Cominform served as a unifier.
Militarily, the US used their deterrent of nuclear weapons, including against Hiroshima and Nagasaki in 1945 to alarm the Soviet Union. This, however, was ineffective in containing communism - it did not scare the USSR and make them compliant to the US. Stalin was encouraged by the US bombs on Japan to develop the USSR's own atomic bomb, which did happen in 1949, much to the unease...