Docker Configuration – Windows Server 2016

How To Install Docker In Windows Server 2016 –


The below post is from a section of a report I completed a few months ago.


The following information is only a brief overview of the work carried out to install and administer Docker on the Windows Server Machine. For a full list of screenshot steps carried out during the installation of Docker please see Appendix 1.

For the purposes of this report a test system was created using VMware Workstation 12. Windows Server 2016 Standard (Desktop Experience) was then installed on the system and work was carried out to try and recreate a Docker container on the system in the form of a Windows Server Container. Below is a brief overview of the work carried out during the process.

This approach was used as the required resources needed to run Hyper-V containers was not available at this moment in time. This is due to the fact that the VM’s run within the base system (Hyper-V Containers) explained before require virtualisation that cannot be utilized within a VMware machine.

The first step in the proses was to create the virtual machine and install the guest operating system. It must be noted that when using VMware to create the virtual machine you must select I will install the operating system later as Easy Install does not at this moment in time support Windows Server 2016.

VM configuration:

  • Microsoft Windows
  • Windows Server 2016
  • Maximum Disk size – 100GB
  • Split Virtual Disk 
  • 2GB Ram
  • 2 Processors

Once the installation of the host operating system is completed the container feature is installed using Windows PowerShell as shown below. PowerShell must be run with administrative privileges for all steps carried out during the configuration.

This may require a restart to take effect.

The container feature should now be installed after the restart of the system and the installation of the Docker engine should now be carried out also. Once Docker has been download and installed it is then started using the Start-Service docker command from Windows PowerShell.

Because Docker is a relatively new technology in the Windows world it is now advised to install all available updates if not already done so. This should hopefully install any new features that Microsoft has created that will help Docker to run smoothly on the system.

The Docker, Windows Containers Feature and all updates should now be installed and ready to run. To verify this several commands below can be used to show information such as Docker version, root directory and if any images are installed.

Please see Appendix 2 for a full list of all steps including Docker testing and image installation.

This command shows important information regarding Docker.

This commands shows that we are using Docker version 1.112.2-cs2-ws-beta.

The next command is used to pull and run an image in a container from the Docker Hub as it is not located locally already on the system and place it in a container that will be started.

It must be noted that the above command only pulls the image from the Docker Hub if it does not already reside locally. To just download (Pull) an image from the Docker hub the Pull command must be used, this does not place the image in a container to be run as it is only downloaded and saved locally.

If the tab flashes blank for a long time without doing anything try pressing enter again as this seems to speed up the process of starting the download and extraction of the Docker image. What this command does is pull the Nano Server image from the Docker Hub, the Docker Engine located on the server then creates a new container and runs it using the new downloaded image.

Once the above process has completed the container should open and the PowerShell prompt should change to the command line from within the container.

As you can see from the above image the user accounts shown now represent the correct container accounts meaning that the command line is running from within the container.

Now that we have confirmed that Docker is working correctly we can exit the container and return to the host systems PowerShell by entering the exit command in the container command line.

We can now run some commands on the base system to verify that the Nano Server image is located on the machine. This is done by issuing the docker images command from within the PowerShell terminal.

This verifies that the Nano Server image is still located on the base machine after the container was exited.

If the container was still open and the cmd was displayed from within it, it is also possible to open another PowerShell terminal on the base system and run the docker ps command to confirm that a container is being run on the system.

The exit command would then be entered again on the container/NanoServer cmd to exit back to the base machine PowerShell and close the container.

As before another image was downloaded from the Docker Hub this time it was the microsoft iis image to try and run a web server from within the container that can be accessed remotely using the IP address of the server.

The iis image is almost 4GB in size and may take some time to download and extract. It must also be noted that the run command used before to create the container had to download the image from the Docker Hub as it was not located locally on the system. If the image already downloaded onto the system, the container would just be started with the specified image stored locally without carrying out a download of the image.

Once the download, extraction of the image is complete and the container is created the default iis website should be accessible from the browser of machine using the IP address of the server machine as shown below.

This website created in the iis container was accessed from the physical windows 10 base machine using the 192.168.0.20 address of the server created in VMware that is running the container. This worked because with the run command used to create the iis container used 80:80 in the command to bind the host port and container port together allowing the host machines IP address to be used.

The docker ps command can also now be used from the host machines PowerShell to confirm the iis container is running.

To demonstrate that it is possible to copy a file from the host windows server 2016 machine to the iis container the following procedure was carried out.

 

  1. html file created on server 2016 machine using notepad and saved to desktop.
  2. PowerShell with admin privileges is opened on server machine and directory changed to desktop.
  3. The docker ps command was used to verify the container id name to be used in following command.
  4. The docker cp index.html 4008266a27b2:/inetpub/wwwroot command was used to copy the html file to the correct directory used to display the iis website.
  5. The docker exec -it 4008266a27b2 powershell command was then used to access the iis container and open the PowerShell from within it.
  6. Once inside the container the cd inetpub/wwwroot command was used to access the directory the file was copied to.
  7. The ls command was then used to verify the file was now located in the correct directory in the container.
  8. Internet explorer on the physical Windows 10 machine was then used to access the new website using the IP address of the virtual machine.
  9. The website should now be displayed.

The long number used in the above example is the container id name gather by issuing the docker ps command at step three.

It must be noted that the docker stop 4008266a27b2 command can be used to stop the container and close it although this was not done at this stage of testing.

Now that we have modified the image within the container we can pause it and save the changes with the following commands.

  • docker pause 4008266a27b2
  • docker commit 4008266a27b2 website

This pauses all processes within the specified container and then commits the changes to a new image called website. This did not work with the current build of docker that was installed but it is a known feature and is reported to work on an updated version of the software.

If the above command had worked the image would have been visible on the server 2016 machine using PowerShell and the docker images command to verify that there was indeed a new image called website stored locally on the system that could be run again using the required run commands to carry on the configuration.

Appendix 1

Docker setup and installation screenshots

Step 1

Step 2

Step 3

Step 4

Step 5

Step 6

Step 7

Step 8

Step 9

Step 10

Step 11

Step 12

Step 13

Appendix 2

Docker testing and administration screenshots

Step 1

Step 2

Step 3

Step 4

Step 5

Step 6

Step 7

Step 8

Step 9

Step 10

Step 11

Step 12

Step 13

Step 14

Step 15

Step 16

Step 17

Step 18

Below is a list of links that may be useful.

Docker – Server 2016

Build Windows Containers 

Windows Containers – 5 Things to know 

1 thought on “Docker Configuration – Windows Server 2016”

Leave a Reply

Your email address will not be published. Required fields are marked *