Requirement is to configure docker image and run IIS based container to install/configure a website using DockerFile.
Here are the steps that needs to be done to implement the above requirement –
- Import microsoft/iis image from the Docker secure registry.
- Create the dockerfile to do the below activities –
a. It installs .net features needed by the application.
b. It copies application published data to the container.
c. It creates and configures website with application pool.
d. It sets .Net trust level.
Note – Using this dockerfile, we can create container anywhere in any windows server 2016 environment.
Here is the content of the dockerfile –
Copy the above content into the text file and name it like dockerfile without any extension. Important note is that this file should not have any extension. Keep it in the same folder where you have kept the web folder (containing the published code of your site ‘abc’).
3. Built the image using the above dockerfile using the command for the location where you have kept the dockerfile – docker build –t [imageName] .
4. Above command creates the image and you can access the list using the command – docker images
5. Once image is created successfully, we need to create the container. It can be created using the command – docker run -d -p 80:80 [ImageName] ping -t localhost
It will create the container. You can get the list of running containers using the command – docker container ls
Complete flow of step 3,4 and 5 is given below –
Once all above steps are done successfully, you can browse your web application using any browser.
If you want to look inside the container, you can run the below commands and it will open the command prompt (cmd or PowerShell) inside the container and then you can using different commands to view the files –
1) For DOS command – docker exec –I [ConatinerID] cmd
2) For PowerShell command – docker exec –I [ContainerID] powershell
———-End of Article———