- A local install of Docker
- A local install of Vagrant
- VMWare or VirtualBox
https://github.com/StefanScherer/windows-docker-machine
$ git clone https://github.com/StefanScherer/windows-docker-machine
$ cd windows-docker-machine
$ vagrant up --provider vmware_desktop 2019-box
- or -
$ vagrant up --provider virtualbox 2019-box
$ docker context use 2019-box
$ docker context use default
This Dockerfile will create a container with Python 3.9, a JVM, git, and Cygwin.
FROM python:3.9
RUN New-Item -Path C:\cygwin -ItemType Directory -Force
RUN (New-Object Net.WebClient).DownloadFile('https://cygwin.com/setup-x86_64.exe', 'C:\cygwin\setup-x86_64.exe')
RUN cmd /c start /wait C:\cygwin\setup-x86_64.exe -qnNdO -R C:/cygwin -s http://cygwin.mirror.constant.com -l C:/cygwin/var/cache/setup -P bash
ENV CYGWIN_HOME=C:\\cygwin
RUN setx path '%path%;C:\cygwin\bin'
RUN python -m pip install --upgrade pip
# To install new cygwin packages like git:
RUN cmd /c start /wait C:\cygwin\setup-x86_64.exe -qnNdO -R C:/cygwin -s http://cygwin.mirror.constant.com -l C:/cygwin/var/cache/setup -P git
# If you need a JVM:
RUN Invoke-WebRequest https://api.adoptopenjdk.net/v3/installer/latest/11/ga/windows/x64/jdk/hotspot/normal/adoptopenjdk?project=jdk -OutFile C:\openjdk11.msi
RUN Start-Process -Wait -FilePath msiexec -ArgumentList /i, "C:\openjdk11.msi", "'ADDLOCAL=\"FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome\"'", "'INSTALLDIR=\"C:\Program Files\Java\jdk-11\"'", /quiet, /norestart -Verb RunAs
CMD C:\Cygwin\bin\bash.exe
docker build -t windowspython .
docker run -it --rm windowspython
You cannot directly mount a directory to the Windows docker container; you must first mount the directory in your Windows VM created by Vagrant and then use the path in the Windows VM as the host path in your docker run
command.
For example, say you mounted a local directory to the E:
drive in the Windows VM you created with Vagrant. You can mount that drive to C:\edrive
in your container by running:
docker run -it --rm -v "e:\\:c:\\edrive" windowspython