0% found this document useful (0 votes)
148 views9 pages

8 Docker Container Platform

The document discusses installing and using Docker on Windows Server 2016. It covers enabling the containers feature, installing Docker, pulling and running Windows container images, attaching to running containers, committing container changes to new images, and verifying IIS is running in a container.

Uploaded by

Amarnath Sankar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
148 views9 pages

8 Docker Container Platform

The document discusses installing and using Docker on Windows Server 2016. It covers enabling the containers feature, installing Docker, pulling and running Windows container images, attaching to running containers, committing container changes to new images, and verifying IIS is running in a container.

Uploaded by

Amarnath Sankar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Docker : Install

Install Docker that is the Operating System-Level Virtualization Tool, that automates the
deployment of applications inside Containers.
On Windows Server 2016, Hyper-V is not required for installing Docker, only [Containers]
feature is needed.
Run PowerShell with Admin and run the command like follows to enable Container feature.
(also possible to enable on [Server Manager] - [Add roles and features] - [Containers].
[1]
After enabling it, Restart Computer.
PS > Enable-WindowsOptionalFeature -Online -FeatureName Containers
After rebooting, run PowerShell with Admin again and run the command like follows to
install Docker.
[2] Answer with Y(es) to questions during the installation.
PS > Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
PS > Install-Package -Name docker -ProviderName DockerMsftProvider

After installing Docker, [Docker Engine] service has been added with [Automatic] Startup
[3]
in Services. Restart computer again.
After rebooting, run PowerShell and run the command like follows to verify installation
[4] normally.
PS > docker version
Docker : Basic Usage

This is the Basic Usage of Docker.


Run PowerShell or Command Prompt to use it.
[1] Download Windows official image and run echo inside a Container.
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

# pull Windows ServerCore image


PS C:\Users\Administrator> docker pull microsoft/windowsservercore
Using default tag: latest
latest: Pulling from microsoft/windowsservercore
3889bb8d808b: Pull complete
d0c71fc8924e: Pull complete
Digest:
sha256:05de0a0ac13d3652bd1f2281b8589459ebb611092e3fe4d8f1be91f1f698426
6
Status: Downloaded newer image for microsoft/windowsservercore:latest

# list images
PS C:\Users\Administrator> docker images
REPOSITORY TAG IMAGE ID
CREATED SIZE
microsoft/windowsservercore latest ea9f7aa13d03
7 weeks ago 11GB

# run echo inside a Container


PS C:\Users\Administrator> docker run microsoft/windowsservercore
powershell -c "echo 'Hello Windows Container World'"
Hello Windows Container World

Connect to the interactive session of a Container with [i] and [t] option like follows. If exit
[2]
from the Container session, the process of a Container finishes.
PS C:\Users\Administrator> docker run -i -t
microsoft/windowsservercore powershell

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\> systeminfo

Host Name: 0CAEA0EB3105


OS Name: Microsoft Windows Server 2016 Datacenter
Evaluation
OS Version: 10.0.14393 N/A Build 14393
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Server
OS Build Type: Multiprocessor Free Registered Owner: N/A
Registered Organization: N/A
Product ID: 00377-90000-00001-AA325
Original Install Date: 1/2/2019, 4:01:44 PM
System Boot Time: 3/4/2019, 12:00:46 AM
System Manufacturer: Red Hat
System Model: KVM
System Type: x64-based PC
Processor(s): 4 Processor(s) Installed.
[01]: Intel64 Family 6 Model 63 Stepping 2
GenuineIntel ~2594 Mhz
[02]: Intel64 Family 6 Model 63 Stepping 2
GenuineIntel ~2594 Mhz
[03]: Intel64 Family 6 Model 63 Stepping 2
GenuineIntel ~2594 Mhz
[04]: Intel64 Family 6 Model 63 Stepping 2
GenuineIntel ~2594 Mhz
BIOS Version: SeaBIOS 1.11.0-2.el7, 4/1/2014
Windows Directory: C:\Windows
System Directory: C:\Windows\system32
Boot Device: \Device\HarddiskVolume1

.....
.....

PS C:\> exit
PS C:\Users\Administrator> # back

If exit from the Container session with keeping container's process, push Ctrl+p, and
[3]
Ctrl+q key.
PS C:\Users\Administrator> docker run -it microsoft/windowsservercore
powershell

Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS C:\> # Ctrl+p, Ctrl+q

PS C:\Users\Administrator>
PS C:\Users\Administrator> docker ps
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS NAMES
5337b53aeb49 microsoft/windowsservercore "powershell"
28 seconds ago Up 25 seconds sharp_wu

# connect to container's session


PS C:\Users\Administrator> docker attach 5337b53aeb49

PS C:\> hostname
5337b53aeb49
PS C:\>

# shutdown container's process from Host's console


PS C:\Users\Administrator> docker kill 5337b53aeb49
e68a751d4b2c

PS C:\Users\Administrator> docker ps
CONTAINER ID IMAGE COMMAND CREATED
STATUS PORTS NAMES
Docker : Add new Container Image
2
Add Images for Containers.
For exmaple, update official image with installing IIS and add it as a new image for
[1] container. The container is generated every time for executing docker run command,
so add the latest executed container like follows.
# show images

PS C:\Users\Administrator>
docker images

REPOSITORY TAG IMAGE ID CREATED


SIZE
microsoft/windowsservercore latest ea9f7aa13d03 7 weeks ago
11GB

# start a Container and install IIS

PS C:\Users\Administrator>
docker run microsoft/windowsservercore powershell -c "dism.exe /online /enable-feature /all
/featurename:iis-webserver /NoRestart"

Deployment Image Servicing and Management tool


Version: 10.0.14393.0

Image Version: 10.0.14393.2457

Enabling feature(s)

The operation completed successfully.

PS C:\Users\Administrator>
(docker ps -a)[0..1]

CONTAINER ID IMAGE COMMAND CREATED


STATUS PORTS NAMES
09df8de48f27 microsoft/windowsservercore "powershell -c 'dism..." About a
minute ago Exited (0) 27 seconds ago determined_ishizaka

# add IIS installed image

PS C:\Users\Administrator>
docker commit 09df8de48f27 srv.world/iis

sha256:134153635645b3785e8daa6ea72c651c9a13c102279ee78b8d686fbf78bccbcd
# show images

PS C:\Users\Administrator>
docker images

REPOSITORY TAG IMAGE ID CREATED


SIZE
srv.world/iis latest 134153635645 44 seconds ago
11.3GB
microsoft/windowsservercore latest ea9f7aa13d03 7 weeks ago
11GB

# Generate a Container from the new image and verify IIS is running

PS C:\Users\Administrator>
docker run srv.world/iis powershell -c "Get-Service | Out-String -Stream | Select-String
'W3SVC'"

Running W3SVC World Wide Web Publishing Service

M a t c h e d C o n t e n t

You might also like