Skip to content

Commit

Permalink
Add support for Windows Server Core 2016, 2022 and friends
Browse files Browse the repository at this point in the history
- windows/servercore:ltsc2016
- windows/servercore:ltsc2022
- windows/nanoserver:ltsc2022
  • Loading branch information
amotl committed Jun 8, 2022
1 parent f31f41a commit e11770d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ in progress
- Add support for Windows Server Core 2019 and friends, like
``windows/servercore:ltsc2019``, ``windows/nanoserver:1809``, or
``eclipse-temurin:17-jdk``.

- Add support for Windows Server Core 2016, 2022 and friends, like
``windows/servercore:ltsc2016``, ``windows/servercore:ltsc2022``, or
``windows/nanoserver:ltsc2022``.

2022-05-20 0.2.0
================
Expand Down
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ Windows examples::
# Nanoserver: 250 MB, Servercore: 6 GB, Servercore with Java: 7 GB, Windows: 15 GB

# Launch an interactive command prompt (cmd, PowerShell or Bash).
racker --verbose run -it --rm --platform=windows/amd64 mcr.microsoft.com/windows/servercore:ltsc2016-amd64 cmd
racker --verbose run -it --rm --platform=windows/amd64 mcr.microsoft.com/windows/servercore:ltsc2019-amd64 powershell
racker --verbose run -it --rm --platform=windows/amd64 mcr.microsoft.com/windows/servercore:ltsc2022-amd64 bash

# Launch a single command.
racker --verbose run --rm --platform=windows/amd64 mcr.microsoft.com/windows/servercore:ltsc2019-amd64 -- 'powershell -Command {echo "Hello, world."}'
Expand All @@ -279,6 +281,7 @@ Windows examples::

# Invoke a Java command prompt (JShell) with different Java versions.
racker run -it --rm --platform=windows/amd64 openjdk:18-windowsservercore-1809 jshell
racker run -it --rm --platform=windows/amd64 openjdk:19-windowsservercore-ltsc2022 jshell
racker run -it --rm --platform=windows/amd64 eclipse-temurin:18-jdk jshell
System.out.println("OS: " + System.getProperty("os.name") + ", version " + System.getProperty("os.version"))
System.out.println("Java: " + System.getProperty("java.vendor") + ", version " + System.getProperty("java.version"))
Expand All @@ -287,9 +290,12 @@ Windows examples::
# Windows Nano Server.
racker --verbose run -it --rm --platform=windows/amd64 mcr.microsoft.com/windows/nanoserver:1809-amd64 cmd
racker --verbose run --rm --platform=windows/amd64 mcr.microsoft.com/windows/nanoserver:1809-amd64 cmd /C echo Hello, world.
racker --verbose run --rm --platform=windows/amd64 mcr.microsoft.com/windows/nanoserver:ltsc2022-amd64 cmd /C echo Hello, world.
racker --verbose run -it --rm --platform=windows/amd64 mcr.microsoft.com/powershell:nanoserver-ltsc2022 pwsh

# Full Windows.
racker --verbose run -it --rm --platform=windows/amd64 mcr.microsoft.com/windows:1809-amd64 cmd
racker --verbose run -it --rm --platform=windows/amd64 mcr.microsoft.com/windows:ltsc2022-amd64 cmd



Expand Down
10 changes: 8 additions & 2 deletions postroj/winrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

class WinRunner:

#BOX = "2016-box"
BOX = "2019-box"
#BOX = "2022-box"
VCPUS = os.environ.get("RACKER_VM_VCPUS", 6)
MEMORY = os.environ.get("RACKER_VM_MEMORY", 6144)

Expand All @@ -44,7 +46,7 @@ def setup(self):
logger.info(f"Installing Windows Docker Machine into {self.wdmdir}")
command = f"""
cd '{self.workdir}'
git clone https://github.com/StefanScherer/windows-docker-machine
git clone https://github.com/cicerops/windows-docker-machine --branch racker
cd windows-docker-machine
#ls -alF
sed -i 's/v.cpus = [0-9]\+/v.cpus = {self.VCPUS}/' Vagrantfile
Expand Down Expand Up @@ -81,7 +83,11 @@ def start(self):
# https://github.com/moby/moby/blob/0e04b514fb/integration-cli/docker_cli_run_test.go
cmd(f"docker --context={self.BOX} ps", capture=True)

if "nanoserver" in self.image_base:
# Skip installing software using Chocolatey for specific Windows OS versions.
# - Windows Nanoserver does not have PowerShell.
# - Windows 2016 croaks like:
# `The command 'cmd /S /C choco install --yes git curl wget' returned a non-zero code: 3221225785`
if "nanoserver" in self.image_base or self.BOX == "2016-box":
self.image_real = self.image_base
else:
self.provision_image()
Expand Down

0 comments on commit e11770d

Please sign in to comment.