Edit Dockerfile for Your Environment
NCache also provides Dockerfiles and supporting resources on GitHub to allow more flexibility while using NCache as a Docker image. You can customize the Dockerfile to create images and containers according to your requirements, and use NCache as a result.
What does NCache Dockerfile contain?
The Dockerfiles provided by NCache at https://github.com/Alachisoft/NCache-Docker contain commands to build images for NCache.
Note that to create the image from this file, the following resources are required:
Dockerfiles can be customized to perform additional tasks. NCache Dockerfiles for Windows Server are placed at GitHub for the following:
NCache Enterprise setup file
This is an .msi file. Download from Alachisoft’s website here.
Microsoft Visual C++ 2010 x64 Redistributable
This is an .exe file and a pre-requisite for NCache - download from Microsoft’s website here.
The IPBinding.ps1 script changes the IP in the NCache configuration files. Hence, it is highly recommended that the IPs provided are static, as all future connections will take place using this IP. In case dynamic IPs have been assigned, the container might be assigned with a new IP (on the next connection) instead of the one stored in the configuration during container creation. This results in NCache service not starting.
You can get the IPBinding.ps1 scripts from GitHub for the following:
These resources must be placed in the following file structure (as also arranged in GitHub):
You can customize the Dockerfile to perform any additional tasks after or before installation.
The following sample Dockerfile has been customized to specify credentials for dummy user David Jones while installing Cache Server edition for NCache Enterprise. It then executes a custom script to activate licensing for NCache using the NActivate.exe tool, once installation has been completed.
# Setting base image for NCache. FROM microsoft/dotnet-framework:4.7.2-runtime # Setting work directory to copy setups and resources for configuring NCache. WORKDIR /app # Make sure that the 2 folders ("resources" and "setup") exist in the same directory as the Dockerfile. # Make sure that "IPBinding.ps1" script resides in the "resources" folder. # Make sure that Microsoft Visual C++ 2010 x64 Redistributable setup is placed in the "setup" folder. It can be downloaded from https://www.microsoft.com/en-us/download/details.aspx?id=14632. # Make sure that NCache setup resides in the "setup" folder. It can be downloaded from http://www.alachisoft.com/download-ncache.html. # Copying resources and setups into the work directory of the container. COPY resources . COPY setup . # Exposing ports used by NCache for communication. # Exposing the port at which NCache service will listen for incoming client connection requests. EXPOSE 9800 # Exposing the port at which NCache service will listen for incoming management connection requests (NCache Tools). EXPOSE 8250 # Installing Microsoft Visual C++ 2010 x64 Redistributable (Pre-Requisite of NCache). RUN vcredist_x64.exe /norestart /q # Installing NCache setup. # The parameter "INSTALLMODE" represents the NCache installation edition and has the following values: # Enterprise Server Edition = "0" # Enterprise Remote Client Edition = "3" The parameter "KEY" is the install key and is sent to user through e-mail once they download NCache setup. In case if user does not get a key, contact us at http://www.alachisoft.com/company/contact-us.html. # The parameter "USERFIRSTNAME" represents the first name of the user. # The parameter "USERLASTNAME" represents the last name of the user. # The parameter "COMPANYNAME" represents the company the user works for. # The parameter "EMAILADDRESS" represents the e-mail address of the user. # The parameter "INSTALLDIR" represents the installation directory where NCache will be installed. # The parameter "/qn" specifies that NCache will be installed silently without user interaction and will not prompt the user for anything. RUN msiexec /i ncache.ent.x64.msi INSTALLMODE="0" KEY="XXXXXXXXXXXXXXXXX" USERFIRSTNAME="David" USERLASTNAME="Jones" COMPANYNAME="Alachisoft" EMAILADDRESS="firstname.lastname@example.org" INSTALLDIR="C:\Program Files\NCache" /qn # Currently, the IP during NCache installation is stored in the configuration files and it can not be made static at that point. # However, the IP can be made static once the container is started. # An IP Binding change task is scheduled to run when the container instance is started. This task replaces the IP with the actual IP assigned to the container. # Creating one time executing IP Binding task that will change the IP in NCache Configuration files on the first time the container is started. RUN schtasks /Create /TN IPBinding /SC ONSTART /TR "c:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe C:\app\IPBinding.ps1" /ru SYSTEM # Run NActivate.exe in %NCHOME%\bin\NActivate to activate licensing online using the license key obtained from email@example.com. You can also manually activate the licensing by specifying the "/m" switch. # Pre-requisites for this are Internet connectivity and DNS Resolution. RUN C:\Windows\System32\cmd.exe /k ""%NCHOME%bin\NActivate\NActivate.exe" /k XXXXXXXX-XXXXXX-XXXXXXXX /f David /l Jones /e firstname.lastname@example.org" # Entry point for the container, once all the required configurations have been made. CMD start –Verbose
Create Images using Customized Dockerfile
Using this customized Dockerfile, you can now create Docker images which will host NCache as specified in Dockerfile.
Go to the relative path where the Dockerfile is placed. In the following examples, it is assumed it is placed in location C:/Docker.
The following docker build command creates image
ncachewith optional tags
enterprise-client-5.0in the format <image_name>:<optional_tag>:
PS C:/Docker> docker build . –t ncache:enterprise-server-5.0
PS C:/Docker> docker build . –t ncache:enterprise-client-5.0
To verify image has been created, run the command
docker images which lists all images and their details.
Save Image to Disk
Once an image is created, you can save it to the disk as a TAR file using docker save. The following commands save the images to the location myLocation with the same image name:
docker save -o "[myLocation]\ncache:server-enterprise-5.0.tar" ncache:enterprise-server-5.0
docker save -o "[myLocation]\ncache:client-enterprise-5.0.tar" ncache:enterprise-client-5.0
You can create containers using these images and proceed to use NCache. Note that for this, the image name should be the same as stored locally.