Skip to content
This repository was archived by the owner on Mar 11, 2020. It is now read-only.

Commit 4fb818f

Browse files
committed
Added IIS docs
Signed-off-by: Elton Stoneman <[email protected]>
1 parent 9ac8738 commit 4fb818f

File tree

2 files changed

+190
-0
lines changed

2 files changed

+190
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
`Image2Docker` is a PowerShell module which ports existing Windows application workloads from virtual machines to Docker images. It supports multiple application types, but the initial focus is on IIS. You can use `Image2Docker` to extract [ASP.NET websites from a VM](https://blog.docker.com/2016/12/convert-asp-net-web-servers-docker-image2docker/), so you can run them in a Docker container with no application changes.
44

5+
## Documentation
6+
7+
* [IIS and ASP.NET](docs/IIS.md)
8+
59
## Introduction
610

711
This project aims to provide a framework to simplify the creation of Dockerfiles for Windows Docker

docs/IIS.md

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
# IIS
2+
3+
Image2Docker can inspect web servers and extract a Dockerfile containing some or all of the websites configured on the server.
4+
5+
ASP.NET is supported, and the generated Dockerfile will be correctly set up to run .NET 2.0, 3.5 or 4.x sites.
6+
7+
## Usage
8+
9+
Use the `IIS` artifact to inspect a web server. To extract all websites from a virtual machine disk image into a Dockerfile, run:
10+
11+
```
12+
ConvertTo-Dockerfile `
13+
-ImagePath c:\iis.vhd `
14+
-OutputPath c:\i2d2\iis `
15+
-Artifact IIS
16+
```
17+
18+
### Selective Extraction
19+
20+
You can limit the extraction using the `ArtifactParam` parameter, which restricts the output to a single wesbite, web application or virtual directory.
21+
22+
Specify the path to the source content using the following format:
23+
24+
| Format | Example | Dockerfile contents |
25+
| --------------------------------- | ------------------------- | --------------------------------------------------------------------- |
26+
| `{website}` | 'UpgradeSample' | Named site with all apps and virtual directories |
27+
| `{website}/{vdir}` | 'UpgradeSample/img' | Named site with only the named virtual directory |
28+
| `{website}/{application}` | 'UpgradeSample/v1.0' | Named site with the named application and all its virtual directories |
29+
| `{website}/{application}/{vdir}` | 'UpgradeSample/v1.0/img' | Named site with the named application the named virtual directory |
30+
31+
If you had the following structure in IIS on the source server:
32+
33+
```
34+
IIS
35+
36+
└── Default Web Site <website>
37+
│ │
38+
│ └── img <vdir>
39+
│ │
40+
│ └── app1 <app>
41+
│ │
42+
│ └── img <vdir>
43+
44+
└── UpgradeSample <website>
45+
46+
└── v1.0 <app>
47+
│ │
48+
│ └── img <vdir>
49+
50+
└── v1.1 <app>
51+
52+
└── v1.2 <app>
53+
```
54+
55+
You can extract the whole configuration into a Dockerfile if you omit `ArtifactParam`.
56+
57+
To extract just the `v1.2` web application, run:
58+
59+
```
60+
ConvertTo-Dockerfile `
61+
-ImagePath c:\iis.vhd `
62+
-OutputPath c:\i2d2\iis `
63+
-Artifact IIS `
64+
-ArtifactParam UpgradeSample/v1.2
65+
```
66+
67+
## Source Types
68+
69+
IIS discovery supports running on VHD and WIM disk images, on the local machine and on a remote machine.
70+
71+
The machine where you run `ConvertTo-Dockerfile` needs to have PowerShell 5.0 installed. It does not need to have Docker installed - you can generate Dockerfiles on one machine and then build them on another.
72+
73+
### Disk Images
74+
75+
The disk image must be available locally, PowerShell does not support mounting images on a network share.
76+
77+
Use the `ImagePath` parameter, specifying the location of the disk image:
78+
79+
```
80+
ConvertTo-Dockerfile `
81+
-ImagePath c:\iis.vhd `
82+
-OutputPath c:\i2d2\iis `
83+
-Artifact IIS
84+
```
85+
86+
### Local machine
87+
88+
PowerShell 5.0 is installed by default on Windows Server 2016, but it is available for Windows Server 2008R2 onwards. Install [Windows Management Framework 5.0](https://www.microsoft.com/en-us/download/details.aspx?id=50395) on older systems before installing `Image2Docker`.
89+
90+
Use the `Local` parameter:
91+
92+
```
93+
ConvertTo-Dockerfile `
94+
-Local `
95+
-OutputPath c:\i2d2\iis `
96+
-Artifact IIS
97+
```
98+
99+
### Remote machine
100+
101+
IIS discovery uses the filesystem almost exclusively, so you can run it against a remote shared drive. The system drive needs to be shared, and the user running `ConvertTo-Dockerfile` needs read permission on the `Windows` directory, and any directories where IIS content is stored.
102+
103+
Use the `RemotePath` parameter:
104+
105+
```
106+
ConvertTo-Dockerfile `
107+
-RemotePath \\192.168.1.11\c$ `
108+
-OutputPath c:\i2d2\iis `
109+
-Artifact IIS
110+
```
111+
112+
Using a remote path means `Image2Docker` can't discover the Windows features installed on the machine, so any optional IIS features installed will not be extracted into the Dockerfile.
113+
114+
## Base Images
115+
116+
IIS discovery will choose the most appropriate base image for the workload it extracts:
117+
118+
* [microsoft/iis:windowsservercore](https://hub.docker.com/r/microsoft/iis/) - for websites which don't use ASP.NET
119+
* [microsoft/aspnet:windowsservercore](https://hub.docker.com/r/microsoft/aspnet/) - for websites which use ASP.NET (2.0 and 4.x)
120+
* [microsoft/aspnet:3.5-windowsservercore](https://hub.docker.com/r/microsoft/aspnet/) - for websites which use ASP.NET 3.5
121+
122+
They are all based on Windows Server Core, which is the Windows 2016 kernel. We pin to the latest version of the base image, so you should check for updates to `Image2Docker` before you run it.
123+
124+
## Sample Dockerfiles
125+
126+
From a remote Windows 2008R2 server, extracting a single ASP.NET website:
127+
128+
```
129+
ConvertTo-Dockerfile -RemotePath \\192.168.1.11\c -OutputPath c:\i2d2\2008-remote -Artifact IIS -ArtifactParam iis-env
130+
```
131+
132+
Produces:
133+
134+
```
135+
# escape=`
136+
FROM microsoft/aspnet:windowsservercore-10.0.14393.693
137+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
138+
139+
RUN Remove-Website 'Default Web Site';
140+
141+
# Set up website: iis-env
142+
RUN New-Item -Path 'C:\iis\iis-env' -Type Directory -Force;
143+
144+
RUN New-Website -Name 'iis-env' -PhysicalPath 'C:\iis\iis-env' -Port 8090 -Force;
145+
146+
EXPOSE 8090
147+
148+
COPY ["iis-env", "/iis/iis-env"]
149+
```
150+
151+
From a local VHD containing a Windows 2003R2 server with .NET 3.5, extracting a nested website:
152+
153+
```
154+
ConvertTo-Dockerfile -ImagePath E:\VMs\win2003-iis.vhd -OutputPath c:\i2d2\2003-vhd -Artifact IIS -ArtifactParam UpgradeSample
155+
```
156+
157+
Produces:
158+
159+
```
160+
# escape=`
161+
FROM microsoft/aspnet:3.5-windowsservercore-10.0.14393.693
162+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
163+
164+
RUN Remove-Website 'Default Web Site';
165+
166+
# Set up website: UpgradeSample
167+
RUN New-Item -Path 'C:\UpgradeSample' -Type Directory -Force; `
168+
New-Item -Path 'C:\images' -Type Directory -Force; `
169+
New-Item -Path 'C:\UpgradeSample\v1.0' -Type Directory -Force; `
170+
New-Item -Path 'C:\UpgradeSample\v1.1' -Type Directory -Force; `
171+
New-Item -Path 'C:\UpgradeSample\v1.2' -Type Directory -Force;
172+
173+
RUN New-Website -Name 'UpgradeSample' -PhysicalPath 'C:\UpgradeSample' -Port 8082 -Force; `
174+
New-WebVirtualDirectory -Name 'img' -Site 'UpgradeSample' -PhysicalPath 'C:\images'; `
175+
New-WebApplication -Name 'v1.0' -Site 'UpgradeSample' -PhysicalPath 'C:\UpgradeSample\v1.0' -Force; `
176+
New-WebApplication -Name 'v1.1' -Site 'UpgradeSample' -PhysicalPath 'C:\UpgradeSample\v1.1' -Force; `
177+
New-WebApplication -Name 'v1.2' -Site 'UpgradeSample' -PhysicalPath 'C:\UpgradeSample\v1.2' -Force;
178+
179+
EXPOSE 8082
180+
181+
COPY ["UpgradeSample", "/UpgradeSample"]
182+
COPY ["images", "/images"]
183+
COPY ["v1.0", "/UpgradeSample/v1.0"]
184+
COPY ["v1.1", "/UpgradeSample/v1.1"]
185+
COPY ["v1.2", "/UpgradeSample/v1.2"]
186+
```

0 commit comments

Comments
 (0)