LET’S TALK DOCKER (PART–3): Dock on Server 2016/Nano
1. First, we need to install windows feature containers with the following command
It will complete very quick. After completing it will display a warning to restart pc.
2. Restart the computer with the following command
3. Create a new folder for Docker executable. For that, run following command
New-Item -Type Directory -Path ‘C:\Program Files\docker\’
4. Now as we have enabled windows container, we also need Docker. Docker has two parts; Docker engine and Docker client.
5. First download Docker engine aka Docker daemon.
Invoke-WebRequest https://aka.ms/tp5/b/dockerd -OutFile $env:ProgramFiles\docker\dockerd.exe
6. Now download Docker client.
Invoke-WebRequest https://aka.ms/tp5/b/docker -OutFile $env:ProgramFiles\docker\docker.exe
Note: Careful with request path and execution as the differences are very small.
Engine path: https://aka.ms/tp5/b/dockerd
Client path: https://aka.ms/tp5/b/docker
Engine exe: dockerd.exe
Client exe: docker
7. Add the Docker directory to the system path by the following command.[Environment]::SetEnvironmentVariable(“Path”, $env:Path + “;C:\Program Files\Docker”, [EnvironmentVariableTarget]::Machine)
Note: We need to restart the computer here. Restarting the PowerShell session (as instructed in MSDN) does not work. After restarting the computer you can check if the path is recognized by the following command.[Environment]::GetEnvironmentVariable(“Path”)
8. Now we can install Docker as window service. Run the following code.
9. Run the following command to check if docker service is added or not.
10. Once installation is done start the service by the following command.
11. Windows containers are deployed from templates or images. Before a container can be deployed, a base OS image needs to be downloaded. The following commands will download the Windows Server Core base image.
12. First, install the container image package provider.
Install-PackageProvider ContainerImage –Force
13. Next, install the Windows Server Core image.
Install-ContainerImage -Name WindowsServerCore
Note: This will take some time, around one hour. We can see the downloading message in the green banner. Once the green banner disappears PowerShell will wait for you to press enter but will not show any message. Yes, it is confusing. We waited thinking it is working. 😛
14. After the base image has been installed, the Docker service needs to be restarted.
15. Now you can list all installed images by following command
16. Search docker hub with search command
‘docker search microsoft’
17. Download the IIS image using docker pull command
Docker pull Microsoft/iis:windowsservercore
18. Deploy IIS container by docker run command.
‘docker run –d –p 80:80 microsoft/iis: windosservercore ping –t localhost’
This command runs the IIS image as a background service (-d for daemon) and configures networking such that port 80 of the container host is mapped to port 80 of the container.
19. We can see running container by docker ps command
- ‘docker ps’ was listing running IIS container
- We installed windows server in a vm. We were not able to ping the host and vm even in bridge network mode. So we cannot see the hosted IIS in host pc.
- We wanted to dock with Nano server. But we failed every time for multiple reasons.
- We downloaded the Nano server NHD, run via VirtualBox and was able to login Nano Server Recovery Console. But network adapter was missing, though we tried different network setting in the VM. So we failed to use it. No adapter => No IP => No remote login => You can do nothing
- You need to be very careful about Technical Preview version and documentation version. You cannot use the latest version command on an older version. It will not work.
- The process is very time consuming, so extra caution is required because if you make any mistake you have to do it again.
- Microsoft is still updating doc and new Technical Preview will change many thing. If it is not working, keep patience and try next week. Documentation may change by then.
Contributor: Sayedur Rahman, Nascenia