Simple Dockerfile to create a custom website
Get started with containers and Docker with a simple Dockerfile.
December 7, 2016
Q. Is there a simple Docker file to create a custom website?
A. I created a VERY simple Docker file that use the microsoft/iis image as its parent (which in turn uses the microsoft/windowsservercore image as its parent) and customize some of the files with those in a local folder. The Docker file contains the following (save this as Dockerfile with no file extension in a new folder). Note Docker is case sensitive.
FROM microsoft/iisRUN del C:inetpubwwwrootiisstart.htmCOPY /website /inetpub/wwwroot
The FROM line specifies the base image this new container image (that will be created from the Docker file) is based on. The RUN line is a command that will be run inside the new container instance and can be any command. In this case it simple deletes the default page for IIS. Note that even though this is a delete command it does not alter the actual microsoft/iis image (which is read-only). Instead it modifies the virtual file system inside the new container image layer to make it appear as if the file does not exist. The final COPY line copies the content of folder website from the local machine into the target folder inside the container image.
You should have a subfolder named website in the same folder you saved Dockerfile to that contains your target website you want to be copied into your container instance. To create the new custom container image navigate to your folder containing the Dockerfile and run:
docker build -t customIIS .
You can then create a container instance based on the custom image using:
docker run --name iisdemo -it -p 80:80 customIIS cmd
This command creates an instance named iisdemo and maps port 80 on the container host to port 80 on the container instance. This allows navigation to the site using the IP address of the host (behind the scene NAT is used). The -it makes it interactive and launches cmd which allows interaction.
Once you are finished exit the container instance and then delete the container instance and even remove the container image (docker rmi customIIS).
About the Author
You May Also Like