Determine how your knees track by either placing your stationary trainer in front of a mirror or videotaping yourself.
There's variance in cycling and running style. Trying to correct these variations and promote "perfect" mechanics can often do more harm than good. Form that's bio-mechanically inefficient, or that's causing overuse injuries should be corrected.
One of the more common issues I see with cyclists is bow-legged or knees-out pedaling. This is almost always inefficient and often causes knee discomfort (or worse). In general, you want to pedal roughly with the hip, knee cap and foot in alignment, but there will be variations based on your individual make up and riding style.
More: 4 Drills to Improve Pedaling Technique
If you're bow-legged, or if you have a leg-length discrepancy it's best to have a professional fit you. This may involve widening your pedal stance (moving the cleat towards the crank arm), or using wedges, shims and spacers to correct leg length discrepancies or cant of the foot.
Often, knees-out tracking and alignment is the result of bad habit or compensation for a previous injury. It's more common in heavier or obese riders. Start by observing how you're pedaling. Position a mirror in front of you as you pedal on your stationary trainer, or better yet use a video camera with slow motion. Aim the camera just below your handlebars. Either of these methods will allow you to identify how your knees track as you pedal.
More: 3 Drills to Practice Pedaling Efficiency
I've used zip ties (see figure below) as a visual marker for knee tracking. Make sure they're equal lengths by measuring from the top tube. The end of the zip tie should roughly bisect your patella as your hip, knee, and foot are in alignment. You can even have the knee slightly brush these to get a feel for your knee position as you pedal.
If you find yourself tracking wide on one or both sides, try bringing the knee(s) in slightly. As long as this doesn't cause pain or discomfort, try riding in this position for short periods of time. If you're able to acclimate, and the position feels more comfortable, then this was probably just a habitual problem. Another option is to try widening your pedal stance to help correct it.
More: A Breakdown of the Pedal Stroke
Inspired? Search for a cycling event