Setting up windows containers offline
*** Please note that this post is meant for dev environments and not for production scenarios ***
Containers and Serverless are all the rage these days, but many enterprise developers do not have internet access on their development VMs. So how do we get started?
To setup windows containers on your machine, you would need few things:
- The 'containers' feature to be enabled on your server
- The Docker tooling – the Docker client and the Docker engine [Needs Internet access]
- The container images themselves [Needs Internet access]
What we can do, in this case, is to use a machine that has internet access and download the required components. Great, but how does it work for container images?
Let's go step-by-step:
On a machine with internet access (I am going to assume a Windows server 2016 standard/datacenter or Windows 10 anniversary/creators update):
Open powershell and install the containers feature. Once completed, restart the machine
Install-WindowsFeature Containers
Download the Docker community edition package from here (pick whichever version you need. As an example - docker-17.09.0-ce.zip). Note that we are using the community edition here and not the enterprise edition of Docker.
Extract the contents to C:\ProgramFiles\docker and add that path to the environment variables
Register dockerd as a service and start it
dockerd.exe --register-service
Start-Service docker
Pull the images that you want to play with, let's say windowsservercore (ver 1709) and aspnetcore
docker pull microsoft/windowsservercore:1709
docker pull microsoft/aspnetcore
Once the download is complete, you can export the images in a tar format, which can then be copied to another machine. Note that the save operation takes time and is based on the size of the image.
docker save -o c:\windowsservercore1709.tar microsoft/windowsservercore:1709
Now, on the server with no internet access:
Open powershell and install the containers feature. Once completed, restart the machine
Install-WindowsFeature Containers
Get the docker package you downloaded from Step #2 and perform Steps #3 and #4
Get the exported images (from Step #6) locally and load them
docker load -i c:\windowsservercore1709.tar
We are now ready to play with containers. To setup an orchestrator, like miniKube follow the detailed instructions here.
Have fun!