Before satellite pictures and numerical models these phenomena were used to forecast the weather. Ancient peoples noted that storms often followed the appearance of a moon or sun dog. And their observations were usually right. In order for a moondog to appear we need to have cirrus clouds in the sky. Cirrus clouds can form along warm frontal boundaries, which are the front runners of storm systems.
Moon/sundogs are created by the same optical principles that produce rainbows. Light from the sun is reflected and refracted by drops in the sky. However in this case, the droplets are frozen. These ice crystals are found in cirrus clouds.