Docker Community Forums

Share and learn in the Docker community.

Python and multi-stage builds

I have got a dockerfile based on the full-fat windows,
ie my first line is -

I then install lots of stuff including an app that requires full windows rather than servercore, nanoserver or iotcore.
Now I want to add python 2.7 to my container.
I struggled doing it manually then I tried adding a second FROM command.

FROM winamd64/python:2

But now I fear that my final image is based on Windows Server 2016 rather than Windows.
Also do I need to use the COPY command to copy stuff from one layer to the other?

I think I could just look at the python dockerfile

and copy it into my dockerfile apart from its first line

Is there a recommended approach?

The strong recommendation is NOT to use Python 2. It has been dead for more than a year and should now be considered an insecure platform. Python 3.10 is an alpha version so it should not be relied on for production workloads. Python 3.9.1 is the current release with Py 3.9.2 scheduled to release in the next few days.

Python can be downloaded from 1. the Microsoft app store, 2. (like above), or 3. we use pyenv to install multiple versions of Python simultaneously in Docker with great success.