Customize NCache Dockerfile
NCache also provides the Dockerfile and supporting resources on GitHub to allow more flexibility while using NCache as a Docker image. You can customize this file to create images and containers according to your requirements, and use NCache as a result.
What does NCache Dockerfile contain?
The Dockerfile provided by NCache contains commands to build images for NCache. It also contains the IPBinding.ps1 script which is explained later.
Note that to create the image from this file, the following resources are required:
- NCache (download from Alachisoft’s website here.)
- Microsoft Visual C++ 2010 x64 Redistributable (download from Microsoft’s website here.)
These resources must be placed in the following file structure:
The Dockerfile provided at GitHub can be customized and used to create an NCache image.
The IPBinding.ps1 script changes the IP in the NCache configuration files on. 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 customize the Dockerfile by specifying any parameters according to your requirements. You can also specify any additional custom scripts to be executed.
The following sample Dockerfile has been customized to specify credentials for David Jones while installing Remote Client edition for NCache Enterprise. It then executes a custom script to activate licensing for NCache using the NActivate tool, once installation has been completed.
# Setting base image for NCache. FROM microsoft/dotnet-framework:4.6.2 # 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 Manager, Monitor and Tools). EXPOSE 8250 # Exposing the port at which Bridge service will listen for incoming connection requests from cache processes. EXPOSE 9900 # Exposing the port at which Bridge service will listen for incoming Management connection requests (NCache Manager and Tools). EXPOSE 8260 # Installing Microsoft Visual C++ 2010 x64 Redistributable (Pre-Requisite of NCache). RUN vcredist_x64.exe /norestart /q # Installing NCache setup. # The parameter "EDITION" 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.client.x64.msi EDITION="3" KEY="XXXXXXXXXXXXXXXXX" USERFIRSTNAME="David" USERLASTNAME="Jones" COMPANYNAME="Alachisoft" EMAILADDRESS="email@example.com" 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 firstname.lastname@example.org. 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 email@example.com" # Entry point for the container, once all the required configurations have been made. CMD start –Verbose
Create Image using Customized Dockerfile
Using the customized Dockerfile, you can now create the desired image to host NCache.
Before proceeding, make sure transparent network has been configured.
Go to the relative path where the Dockerfile is placed. The following docker
ncache with an optional tag
docker build . –t ncache:server-enterprise-4.9
To verify image has been created, run the command
docker images which
lists all images and their details like tag name, image ID and size.
Save Image to Disk
Once an image is created, you can save it to the disk as a TAR file. The
following docker run command saves the
ncache:server-enterprise-4.9 image to the location
C:\DockerImages with the same image name:
docker save -o "C:\DockerImages\ncache:server-enterprise-4.9.tar" ncache:server-enterprise-4.9
You can create containers using these images and proceed to use NCache as specified in Using NCache Docker Images. Note that the image name should be the same as stored locally.