Skip to content

Commit 6707b54

Browse files
Merge pull request #85 from cicerops/windows-2022
Add support for Windows Server 2022
2 parents e801c4c + fa3873d commit 6707b54

File tree

3 files changed

+44
-15
lines changed

3 files changed

+44
-15
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2017 Stefan Scherer
3+
Copyright (c) 2017-2022 Stefan Scherer
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

README.md

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ containers and the Windows containers.
1212
There are several versions of Windows Server. This is where you
1313
decide which Vagrant VM should be started.
1414

15+
* `2022-box` - Windows Server 2022 (10.0.20348) LTS Channel, ___***prebuilt from Vagrant Cloud***___
16+
* `2022` - Windows Server 2022 (10.0.20348) LTS Channel
1517
* `2019-box` - Windows Server 2019 (10.0.17763) LTS Channel, ___***prebuilt from Vagrant Cloud***___
1618
* `2019` - Windows Server 2019 (10.0.17763) LTS Channel
1719
* `1903` - Windows Server, version 1903 (10.0.18362) Semi-Annual Channel
@@ -26,30 +28,37 @@ So with a `vagrant up 2019` you spin up the LTS version, with `vagrant up 1903`
2628
the 1903 semi-annual version and with `vagrant up insider` the Insider build.
2729

2830
If you don't want to run the **packer** step, you can run `vagrant up 2019-box`
29-
and get your box downloaded directly from [Vagrant Cloud](https://app.vagrantup.com/StefanScherer/boxes/windows_2019_docker).
31+
or `vagrant up 2022-box` to get your box image downloaded directly from Vagrant
32+
Cloud. That uses the box images [windows_2019_docker], respectively
33+
[windows_2022_docker].
3034

31-
Tested environments
35+
[windows_2019_docker]: https://app.vagrantup.com/StefanScherer/boxes/windows_2019_docker
36+
[windows_2022_docker]: https://app.vagrantup.com/StefanScherer/boxes/windows_2022_docker
3237

33-
* macOS with Vagrant 2.2.4
38+
## Tested environments
39+
40+
* macOS with Vagrant 2.2.19
3441
* VMware Fusion Pro 11.0.3
35-
* VirtualBox 5.2.26
42+
* VirtualBox 5.2.26 and 6.1.34
3643
* Windows with Vagrant 2.2.4
3744
* VMware Workstation Pro 15.0.3
3845
* (VirtualBox see issue
3946
[#2](https://github.com/StefanScherer/windows-docker-machine/issues/2))
4047
* (Hyper-V see issue
4148
[#1](https://github.com/StefanScherer/windows-docker-machine/issues/1))
4249

43-
#### Before you begin
50+
## Getting started
4451

45-
First you need the Windows Server 2019 VM for your hypervisor. I prefer
52+
First you need a Windows Server VM for your hypervisor. I prefer
4653
"Infrastructure as Code", so every build step is available on GitHub.
4754

4855
![packer vagrant docker](images/packer_vagrant_docker.png)
4956

5057
1. (optional) **packer build** to build a Vagrant base box, it's like a Docker image, but
5158
for Vagrant VM's.
52-
2. **vagrant up** to create a running VM instance of Windows Server, either using the `packer build` or by using one of the pre-built vagrant cloud binaries: `2019-box` or `2016-box`.
59+
2. **vagrant up** to create a running VM instance of Windows Server, either using the
60+
`packer build` or by using one of the pre-built Vagrant Cloud binaries
61+
`2022-box`, `2019-box`, or `2016-box`.
5362
3. **docker run** to run Windows containers in that Windows VM
5463

5564
Step 1 (building the headless Vagrant box) can be done with these steps:
@@ -58,6 +67,11 @@ Step 1 (building the headless Vagrant box) can be done with these steps:
5867
$ git clone https://github.com/StefanScherer/packer-windows
5968
$ cd packer-windows
6069

70+
$ packer build --only=vmware-iso windows_2022_docker.json
71+
$ vagrant box add windows_2022_docker windows_2022_docker_vmware.box
72+
73+
- or -
74+
6175
$ packer build --only=vmware-iso windows_2019_docker.json
6276
$ vagrant box add windows_2019_docker windows_2019_docker_vmware.box
6377

@@ -94,8 +108,8 @@ swap `vmware` for `virtualbox` in the vagrant commands above.
94108

95109
### Create the Docker Machine
96110

97-
Spin up the headless Vagrant box you created earlier with Windows Server 2019 and Docker EE
98-
installed. It will create the TLS certs and create a `2019-box` Docker context (new with Docker 19.03) and docker-machine configuration on your Mac.
111+
Spin up the headless Vagrant box you created earlier. It will create the TLS
112+
certificates and a corresponding Docker context called `2022-box` or `2019-box`.
99113

100114
```bash
101115
$ git clone https://github.com/StefanScherer/windows-docker-machine
@@ -107,6 +121,9 @@ $ vagrant up --provider vmware_desktop 2019-box
107121
$ vagrant up --provider virtualbox 2019-box
108122
```
109123

124+
If you want to use Windows Server 2022, type `2022-box` here instead.
125+
126+
110127
### List your new Docker machine
111128

112129
```bash
@@ -186,7 +203,7 @@ Just use `C:$(pwd)` to prepend a drive letter.
186203
$ docker run -it -v C:$(pwd):C:$(pwd) mcr.microsoft.com/windows/servercore:1809 powershell
187204
```
188205

189-
Yes, this mounts the current directory through the Windows 2019 VM into the
206+
This mounts the current working directory through the Windows VM into the
190207
Windows Container.
191208

192209
### Accessing published ports of Windows containers
@@ -208,8 +225,8 @@ $ open http://$(docker-machine ip 2019-box):8080
208225

209226
## Working on Windows
210227

211-
Spin up the headless Vagrant box you created earlier with Windows Server 2019 and Docker EE
212-
installed. It will create the TLS certs and create a `2019-box` Docker context and docker-machine configuration on your Windows host.
228+
Spin up the headless Vagrant box you created earlier. It will create the TLS
229+
certificates and a corresponding Docker context called `2022-box` or `2019-box`.
213230

214231
If you haven't worked with `docker context` yet, create the `.docker` directory
215232
in your user profile manually.
@@ -236,7 +253,9 @@ PS C:\> vagrant up --provider virtualbox 2019-box
236253
PS C:\> vagrant up --provider hyperv 2019-box
237254
```
238255

239-
Notice: The provider `hyperv` does mount the volumes with SMB into the Windows Server 2019
256+
If you want to use Windows Server 2022, type `2022-box` here instead.
257+
258+
Notice: The provider `hyperv` does mount the volumes with SMB into the Windows Server
240259
VM. It seems that there is a problem mounting that further into a Windows
241260
container. The provisioning (creating the TLS certs and copying them back to the
242261
Windows host) will fail.
@@ -320,7 +339,7 @@ Just use `$(pwd)` in PowerShell.
320339
PS C:\> docker run -it -v "$(pwd):$(pwd)" mcr.microsoft.com/windows/servercore:1809 powershell
321340
```
322341

323-
Yes, this mounts the current directory through the Windows 2019 VM into the
342+
This mounts the current working directory through the Windows VM into the
324343
Windows Container.
325344

326345
### Accessing published ports of Windows containers

Vagrantfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ Vagrant.configure("2") do |config|
5050
cfg.vm.provision "shell", path: "scripts/create-machine.ps1", args: "-machineHome #{home} -machineName 2019-box"
5151
end
5252

53+
config.vm.define "2022", autostart: false do |cfg|
54+
cfg.vm.box = "windows_2022_docker"
55+
cfg.vm.provision "shell", path: "scripts/create-machine.ps1", args: "-machineHome #{home} -machineName 2022"
56+
end
57+
58+
config.vm.define "2022-box", autostart: false do |cfg|
59+
cfg.vm.box = "StefanScherer/windows_2022_docker"
60+
cfg.vm.provision "shell", path: "scripts/create-machine.ps1", args: "-machineHome #{home} -machineName 2022-box"
61+
end
62+
5363
config.vm.define "insider", autostart: false do |cfg|
5464
cfg.vm.box = "windows_server_insider_docker"
5565
cfg.vm.provision "shell", path: "scripts/create-machine.ps1", args: "-machineHome #{home} -machineName insider"

0 commit comments

Comments
 (0)