Rainbows are made from light reflected off tiny droplets of water in the air. That but that light isn't just reflected (bounced back), it's also refracted (bent). When it bounces through the droplet, it's bent at different angles and bounces back toward your eyes. Those different angles are what make the different colors of the rainbow.
Those colors always come in the same order, with red on the top of the rainbow (because it's refracted the least) and violet on the bottom (because it's refracted the most). Check out this fun song to learn the colors of the rainbow in order, and remember that the order goes from the outside of the rainbow to the inside. (When you watch the video, watch for refracting light and the order of the colors, but keep an eye out for things that aren't so scientific as well. :)
This is the same for the big rainbows you see after it rains and small rainbows you see when the sprinklers are on. And it also means that anytime you see a rainbow, the sun is behind you!
The surface of the CD does the same thing as the water droplets in a rainbow--it bends the light! If you shine your flashlight on the back of the CD, a rainbow will appear on the wall or the ceiling. Try moving the rainbow by tilting the flashlight and CD or changing the distance between the two. And check out this video or this article for more great info about the science behind rainbows!