Socialism and capitalism are related to communism in different ways.
Capitalism is the antithesis of communism. Capitalism is a system (according to Marx) in which the bourgeoisie oppresses and exploits the working class (the proletariat). The working class will, after a time, defeat the capitalists in class struggle and capitalism will die off. So capitalism is the evil that communism is meant to remedy.
Socialism is a sort of half-way stage between capitalism and communism. In socialism, the workers have come to control the means of production. However, they have done so through democratic means rather than through revolution. There is still a government, which has not completely faded away as it will once communism is established.
So, capitalism is the mode of production that existed in Marx's time (and in ours). The class struggle was supposed to kill capitalism and would probably go in stages. Socialism would arise and then later full communism would take its place.
Communism is the imposition of socialism by any and all means, violent and nonviolent, without regard to any ethical norm. See "The Naked Communist", by W. Cleon Skousen.
As Lenin said: "The absolute necessity in principle of combining illegal with legal work is determined not only by the sum total of the specific features of the present period ... It is necessary, immediately, for all legal Communist Parties to form illegal organizations for the purpose of systematically carrying on illegal work ... Illegal work is particularly necessary in the army, the navy and police." V.I. Lenin, "SELECTED WORKS," Vol. X, pp. 172-173.
Or put another way, according to VYSHINSKY: "In our state, naturally there is and can be no place for freedom of speech, press, and so on for the foes of socialism. Every sort of attempt on their part to utilize to the detriment of the state -- that is to say, to the detriment of all the toilers -- these freedoms granted to the toilers, must be classified as a counter-revolutionary crime." Vyshinnsky, "LAW OF THE SOVIET STATE," (MacMillan Co., New York, 1948), p. 617
Or Lenin, again: "Dictatorship is power based upon force and unrestricted by any laws. The revolutionary dictatorship of the proletariat is power won and maintained by the violence of the proletariate against the bourgeoisie -- power that is unrestricted by any laws." V.I. Lenin, "SELECTED WORKS," Vol. VII, p. 123.