I am trying to get a Windows docker container running with Python3 using my Gitlab pipeline script. But it seems that the yaml configuration below only starts a Linux docker container. How can I configure my .yml file to start a Windows image with the latest version of python?
.gitlab-ci.yml:
image: python:latest
2
Answers
You’re getting the linux version of the python container because GitLab’s shared runners use linux. Due to how containers work, they share the kernel of the host machine, so a linux runner can’t "host" a windows container – it simply doesn’t have the kernel instructions to run it.
If you want to run a windows docker image, you will need to have a windows server with a supported version that you’re self hosting. You will also need to ensure that the windows docker container you’re using works properly.
All of this having been said – if you’re trying to use python, just run it in Linux. It seems like there are vanishingly few reasons you would need python to be running specifically on windows for your CI/CD, but if you let us know what they are we may be able to help.
There is one other answer and that is Pywine. It emulates a windows inside of a linux for python.
It therfore is:
A docker runner than opens another docker runner that emulatates windows that can be used to solve this. Down below you will find my setup for this:
This is by far not the best setup but it works for me. As a docker image i am using tobix/pywine:3.9. If you find a better way please tell me. I would be very happy to improve the setup.
Please note that everything I didn’t need to run on windows runs in an normal docker container to be more efficient.