Docker on Windows Server 2016 (Part 2)
Follow along to learn how how to configure Docker on a Windows 2016 virtual machine.
Join the DZone community and get the full member experience.
Join For FreeThis blog is part of a multi-part series. The first part showed how to set up Windows Server 2016 as a VirtualBox VM. This second part will show how to configure Docker on Windows 2016 VM.
Start an elevated PowerShell session: Run the script to install Docker:
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
Restart-Computer -Force
This will install the PowerShell module, enable containers feature and install Docker.
The VM needs to be restarted in order for the containers to be enabled. Refer to Container Host Deployment – Windows Server for more detailed instructions.
The VM reboots. Start a PowerShell and check the Docker version using docker version
:
More details about Docker can be found using the
docker info
command:
Run your first Docker container using the docker run -it -p 80:80 microsoft/iis
command:
This will download the Microsoft IIS server Docker image. This is going to take a while so please be patient!Once the 8.9 GB image is downloaded (after a while), the IIS server is started for you. Check the list of images using the
docker images
command and the list of running containers using the docker ps
command:
More details about the container can be found using the
docker inspect
command:
[
{
"Id": "c15555e4b60ec24bbad2b8834c82e14313d193e07da2ca7d3948802e36f4d828",
"Created": "2016-10-27T23:45:20.4069634Z",
"Path": "C:\\ServiceMonitor.exe",
"Args": [
"w3svc"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 4228,
"ExitCode": 0,
"Error": "",
"StartedAt": "2016-10-27T23:45:34.5990616Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:b6a44de60ef92f9eceb68effcfc5fdbd5ecb53677e8c4f1e8dcd02b0c11cb760",
"ResolvConfPath": "",
"HostnamePath": "",
"HostsPath": "",
"LogPath": "C:\\ProgramData\\docker\\containers\\c15555e4b60ec24bbad2b8834c82e14313d193e07da2ca7d3948802e36f4d828\\c15555e4b60ec24bbad2b8834c82e14313d193e07da2ca7d3948802e36f4d828-json.log",
"Name": "/cocky_mahavira",
"RestartCount": 0,
"Driver": "windowsfilter",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"80/tcp": [
{
"HostIp": "",
"HostPort": "80"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 0,
"ConsoleSize": [
50,
120
],
"Isolation": "process",
"CpuShares": 0,
"Memory": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": -1,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0
},
"GraphDriver": {
"Name": "windowsfilter",
"Data": {
"dir": "C:\\ProgramData\\docker\\windowsfilter\\c15555e4b60ec24bbad2b8834c82e14313d193e07da2ca7d3948802e36f4d828"
}
},
"Mounts": [],
"Config": {
"Hostname": "c15555e4b60e",
"Domainname": "",
"User": "",
"AttachStdin": true,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": true,
"Env": null,
"Cmd": null,
"ArgsEscaped": true,
"Image": "microsoft/iis",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"C:\\ServiceMonitor.exe",
"w3svc"
],
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "b23c5766990bb9373e6cbb69cb54b011f57974ed381e60c1eacb7c3c47e303b2",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "80"
}
]
},
"SandboxKey": "b23c5766990b",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"nat": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "9ae352610731342dde19246e759944e79af7a19077d879024a17cedca4b061c9",
"EndpointID": "198d0a52838f1e5178b3fedc154e9f18409c13f0de489e99c06faf9ed2fbedd9",
"Gateway": "",
"IPAddress": "172.26.192.89",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "00:15:5d:7e:60:60"
}
}
}
}
]
The exact IP address of the container can be found using the command:
docker inspect --format '{{ NetworkSettings.Networks.nat.IPAddress }}' cocky_mahavira
The IIS main page is accessible at http://<container-ip>, as shown below:
The next part will show how to create your own Docker image on Windows Server 2016.
Published at DZone with permission of Arun Gupta, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Apache Kafka vs. Message Queue: Trade-Offs, Integration, Migration
-
File Upload Security and Malware Protection
-
Logging Best Practices Revisited [Video]
-
Redefining DevOps: The Transformative Power of Containerization
Comments