Cooling down a container in outer space

The container on Earth will be cooled by convection currents i.e. it transfers heat to the air around it, and also by black body radiation. By contrast the container in space can only cool by black body radiation, and obviously it will cool down more slowly. You can calculate the cooling in space using the Stefan-Boltzmann law assuming you know the emissivity (if you paint the container black the emissivity will be close to unity). Calculating the cooling in air is harder; typically you'd use Newton's law with empirically derived constants.

The final temperature in air is obviously just the temperature of the air around your container. The final temperature in space depends on where your container is. Just as the container can lose heat by emitting radiation it can gain heat by absorbing radiation, and space is full of radiation. For example the Moon is just a lump of inert rock with little or no internal generation of heat, however by absorbing sunlight the daytime temperature can rise to over 100ºC. However at night, when there is no sunlight the temperature can fall to -150ºC. So the final temperature of your container would be different during the lunar night and day, even though it's in a vacuum in both cases. If you took your container into intergalactic space, well away from any radiation sources, then it would indeed cool to the 2.7K of the cosmic microwave background.