When customers try to deploy their customized image with
ACI, they may meet problems. This article provides a workaround for this
problem.
Problem
If you customize an image with the following commands:
docker pull microsoft/iis:nanoserver
docker run --name 2048 -d -v C:\2048:C:\data microsoft/iis:nanoserver
docker exec -i 2048 powershell
#inside the container
mkdir C:\sitecontent
copy-item C:\data\* C:\sitecontent -Recurse
Import-Module IIS*
stop-iissite -name "Default First Site" -confirm:$false
remove-iissite -name "Default First Site" -confirm:$false
new-iissite -name demosite -physicalpath C:\sitecontent -bindinginformation "*:80:"
#exit out of the container
docker stop 2048
docker commit 2048 2048_v1
docker login
docker tag 2048_v1 <dockertag>:2048_v1
docker push <dockertag>:2048_v1
docker run --name 2048 -d -v C:\2048:C:\data microsoft/iis:nanoserver
docker exec -i 2048 powershell
#inside the container
mkdir C:\sitecontent
copy-item C:\data\* C:\sitecontent -Recurse
Import-Module IIS*
stop-iissite -name "Default First Site" -confirm:$false
remove-iissite -name "Default First Site" -confirm:$false
new-iissite -name demosite -physicalpath C:\sitecontent -bindinginformation "*:80:"
#exit out of the container
docker stop 2048
docker commit 2048 2048_v1
docker login
docker tag 2048_v1 <dockertag>:2048_v1
docker push <dockertag>:2048_v1
and they deploy the image with ACI, you may see the following
error from log:
"Service 'w3svc' has been
stopped
APPCMD failed with error code 183
Failed to update IIS configuration"
APPCMD failed with error code 183
Failed to update IIS configuration"
Workaround
It seems that the IIS docker image has a bug similar to https://github.com/Microsoft/iis-docker/issues/42.
We can work around this problem before the bug is fixed. If
we build the docker image from Docker file, then we can successfully deploy it
with ACI.
1.
Define
a Dockerfile, as shown below, supposing your site content files are in the
folder ./source of the path which contains the Dockerfile:
FROM microsoft/iis:nanoserver
RUN powershell -NoProfile -Command Remove-Item -Recurse C:\inetpub\wwwroot\*
WORKDIR /inetpub/wwwroot
COPY source/ .
RUN powershell -NoProfile -Command Remove-Item -Recurse C:\inetpub\wwwroot\*
WORKDIR /inetpub/wwwroot
COPY source/ .
2.
Build
Docker image with command “docker build -t
<your-image-name> .”
and push it into Docker hub with command “docker push <your-image-name> .”
3.
Deploy
the image into ACI with CLI command: az container
create --resource-group <your-resource-group> --name
<your-container-group> --image <your-image-name> --os-type Windows
--port 80 --ip-address "Public"
No comments:
Post a Comment