Mastering Windows Server 2016 Hyper-V

(Romina) #1

docker rm demo1


Although in this example I am only running the container interactively, I can enable
roles and features, change files, and configure my application. Once I delete the
container, all of the changes I made would be lost. If you create a configuration inside
a container and wish to save it as a new image that can then be used by other future
containers, use the docker commit command.
There is a better way, however.


Remember that one of the major pain points with traditional deployment was a lack of
consistency in deployment. Using images provides the immutability that if the same
layer of images is used, the output will be the same. However, if manual steps are then
performed in the container instance, some of the benefit is lost. Instead, a better
option is to use a Dockerfile, which is a prescriptive list of actions to perform to build
a new image that contains all of the configuration. This continues the immutability of
the deployment between environments and provides a much cleaner experience.


A Dockerfile is a simple text file, but many actions are available. The following are
useful links to enable you to continue your learning about Dockerfiles:


Microsoft   Dockerfile  page—https://msdn.microsoft.com/en-
us/virtualization/windowscontainers/docker/manage_windows_dockerfile
Docker Dockerfile documentation
—https://docs.docker.com/engine/reference/builder/

In my modest example, I’m going to create a simple web server. I will base this on the
microsoft/windowsservercore base OS image. Although I could manually install IIS
and then add my custom site, instead Microsoft has an IIS image available in Docker
Hub that I will pull down to run on the windowsservercore base OS. I will then add my
custom site on top of the IIS image and save it as a new image, which I can use to run
a container instance.


First, I search for an IIS image and then download the IIS image from Docker Hub:


PS C:> docker search iis
NAME DESCRIPTION
STARS OFFICIAL AUTOMATED
microsoft/iis Internet Information Services (IIS)
instal... 26
friism/mono
3 [OK]
shawnyhw6n9/centos IISI Security Server Environments
2 [OK]
xluiisx/odoo-ubuntu odoo instance for ubuntu 14.04
0 [OK]
jacekkow/bamboo-agent-rich-iisg Customization of bamboo-agent-rich
0 [OK]


PS C:> docker pull microsoft/iis
Using default tag: latest
latest: Pulling from microsoft/iis

Free download pdf