These two ideologies are not necessarily opposed to one another. A country can act in a colonialist way while still being communist.
Communism is a system of running a given country. It emphasizes governmental control of the economy. It is typically authoritarian and even totalitarian.
Colonialism is a system in which one country exploits another country. The colonizer treats the colony in a way that is good for the colonizer but does not have any real regard for the good of the colony. It is not a system that has anything to do with the political or economic system within the colonizer.
Therefore, a country can be communist at home and can still colonize other countries. These are, then, very different types of ideologies or systems that are not directly opposed to one another.
Communism refers to the way in which a government directs its economy. In a purely communist system, the means of production, which are land, labor, and capital, are owned in common by the working class. In the Soviet Union, the government owned the means of production.
Colonialism, unlike communism, refers to the way in which one country governs another country. The colonial power exploits the other country to extract raw materials and to find a market for its finished goods. For example, in the 1800s, Belgium controlled the Congo Free State as a colony (though it was officially owned personally by the Belgian king, Leopold). Belgium extracted ivory and rubber from the Congo by relying on slave labor and mass executions. This system is very different than the purest forms of communism, in which workers are supposed to control the means of production and the class system is supposed to collapse. In practice, however, communist countries such as the Soviet Union were colonial powers in countries such as Poland and Hungary before the collapse of the Soviet system.