This is a common question in both yoga and Pilates when looking at essentially any pose or exercise where the pelvis is stable and the thigh bone is externally rotated inside of the hip joint. Consider the yoga poses Warrior I and II, Tree and Pigeon, and Pilates exercises such as Standing Pumping Side and Up Down Side on the Wunda Chair; and Short Box Open the Hip, Bottom Lift and Front Splits on the Reformer.
Often knee pain or discomfort arises because we are looking for a shape to place our bodies into instead of considering more deeply the purpose of the exercise. Take, for example, Figure 4 Stretch. Many aim for knee to ankle/foot alignment - a straight line from ankle to knee with the shin perpendicular to the front edge of the mat. What we should be looking at is how much our hip is opening. If the knee or ankle end up opening more than the hip, the knee and ankle will become torqued and pulled at unnaturally and unhealthily. If we mindfully observe the true opening of the thigh at the hip joint we can experience hip opening, groin opening, inner thigh stretching, piriformis stretching, and outer hip, glute and hamstring strengthening without causing pain, discomfort or injury to the knee.
Doug Keller offers an excellent short video on finding how much our hip can open. Try it home and bring the knowledge with you into your group or private lessons. Your knees will thank you!