It does. The planet Mercury is 28.5 million miles away from the Sun and the temperature on the planet reaches 800 degrees Fahrenheit (430 degrees Celsius). Because the planet has no atmosphere to retain that heat, night time temperatures on the surface can drop to -280 degrees Fahrenheit (-170 degrees Celsius). You do get some ice formation on Mercury but only at the bottom of very deep craters where the suns light never penetrates.
AFAIK the same is also true for the moon in orbit of Earth. Water is not present in any form other than ice, and that's only possible in shadowed areas. The lunar impactor that struck the moon recently was a demonstration of this.
Further, both the moon (which is tidally-locked with Earth) and Mercury (which is getting closer to tidal locking with the Sun) have long rotational periods. The Moon is roughly 28 days, while Mercury is closer to 59 days. Under those conditions, both surfaces are exposed to solar radiation long enough to ensure that the temperature of the surface never stays below the freezing point of liquid water for long enough to allow it to form from Hydrogen, Oxygen, or water molecules already present nearby.
The complexity of why water does not form and remain in the vicinity of Mercury and the moon is far beyond a simple case of how much thermal energy is being output by the sun.
At 2 million miles the temperature would be much, much hotter and there would be no formation of ice on the metal skin of a space ship as even the side of the ship that's in shadow would be heated. If not by direct sunlight, then certainly by conduction of heat from the hot side of the ship and also convection from the heat of the surrounding space.
But heat convection needs a medium to work through, and there isn't one in a vacuum. The shaded side of any object is going to get colder over time regardless of distance from a heat source if it doesn't have any opportunity to face the source itself. The amount of time this takes is not going to be in the order of a few minutes, hours, or even days, as it takes time to radiate heat off of an object (conversely it takes time for thermal radiation to heat up a surface when there's nothing to convect said thermal radiation from source to destination), but it's nevertheless a fairly-well understood process.
However, point taken about heat transfer through the ship itself, although again, this won't happen quickly, since radiation takes time to heat up a given object without convection, and the lit side of the ship would take time to heat up.
The other aspect to consider is that liquid water cannot exist at all in a vacuum. The Triple-point of water at zero-pressure is such that the boiling point of water is the same, or lower (I'm not looking it up at this moment in time, so it's off the top of my head) than the freezing point of water.
Even if the surrounding space was only 270 Kelvins (-1 Centigrade or 30-31 Fahrenheit for you US folks) any liquid water released into the vacuum of space would boil away in just a few seconds at most.
This is most easily seen in comets, for those who are farther out than the Earth's orbit can still be seen to vent gaseous water into space. This is not a fast process either, as the comets will have had to travel for some months through space, gradually receiving heat from the output of the sun over a long period of time.
The take-away from this is that, while technically correct that ice cannot form on sunlit-sides of planets and bodies in the vacuum of space, this does not apply to pressurised systems where liquid water can have a chance to form, and therefore water ice can form as a consequence inside e.g. a pressurised cockpit.