Getting Started with Docker
Docker enables you to deliver software quickly by separating your applications from your infrastructure.
Thus, Docker acts as an “isolated, resource controlled, and portable operating environment” that can host any specific application on any machine without the hassle of deploying the environment manually.
NCache provides NCache Enterprise for Windows and Linux Server hosted on the Docker Hub. Once the Docker environment has been set, according to its prerequisites, you can pull the relevant images to start working on NCache.
Using these images, you can create containers that host NCache or create your own customized images by modifying the Dockerfiles.
NCache Docker Images on Docker Hub
The easiest and quickest way to start using NCache is to fetch a pre-built NCache Docker Image from Docker Hub. These Docker images come preinstalled with NCache. Simply use “docker pull” command to install them in your environment. To get started with Docker in NCache, follow the steps mentioned below:
- Install Docker.
- Verify the correct installation by using the following:
docker version
If you are unable to get the version number, check Docker Troubleshooting section.
- Pull the NCache Docker image from Docker Hub
docker pull alachisoft/ncache:latest
Start Docker Container
After pulling the Docker image, you must start a Docker container on the relevant box.
Server and Dev/QA Server
For a stable configuration and seamless integration, we strongly recommend utilizing the host network configuration for NCache deployments. This choice ensures that containers have direct access to the host's network interfaces and share the same IP and Mac address. Unlike the bridge network, which provides isolation between containers connected to the same network, the host network eliminates the need for explicit port mapping. Hence, bridge network is not recommended for NCache deployments.
Note
The NCache Docker container for NCache Server on Linux is set up through host mode networking, i.e., from the network's perspective, the applications inside the container are running on the host itself.
docker run --name ncache -itd --network host alachisoft/ncache:latest
Note
Please note that ncache
used in the command is the name of the container. You can choose any desired name for the container.
Dev Workstation
This allows developers to create a NCache container on their workstations for developing, debugging, and testing client applications. Run the following command using the host network:
docker run --name ncache itd --network host alachisoft/ncache:latest
Connect to Container
Once the NCache containers are created and running, you can access these containers by using docker exec command and specifying the container name of the newly created container.
Windows
The following command connects you to the container ncache using the docker exec command and opens a PowerShell instance within it.
docker exec -it ncache PowerShell
Linux
The following command connects you to the container ncache using the docker exec command:
docker exec -it ncache bash
Register NCache
In order to use NCache, you first need to register your Docker container. You can either register for free evaluation or activate NCache by selecting Activate with License Key.
Note
The default registration type for NCache is Cache Server, you can change this by updating the value of the RegisterAs
flag.
Note
To activate your NCache license, you need to have the license key from Alachisoft Sales.
Windows
Register NCache Using Installation Key
You need to specify the installation types through the RegisterAs
flag when registering a Docker container. The installation types can be Cache Server (default), Remote Client, or Developer. To do so, use the following command:
Register-NCacheEvaluation -Key xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -FirstName John -LastName Smith -Email john@yourdomain.com -RegisterAs Developer -Company your_company_name
Register NCache with the Purchased License Key
You need to specify the registration type through the RegisterAs
flag when registering a Docker container. The registration types can be Cache Server, Remote Client, or Developer. To do so, use the following command:
Register-NCache -Key xxxxxxxxx-xxxxxx-xxxxxxxx -Environment Production -FirstName John -LastName Smith -Email john@yourdomain.com -RegisterAs Developer -Company your_company_name
Linux
Register NCache Using Installation Key
You need to specify the registration type through the registeras
flag when registering a Docker container. The registration types can be Cache Server, Remote Client, or Developer. To do so, use the following command:
Note
The "register-ncacheevaluation" command line tool is located in the $NCHOME/bin/tools
folder. If the $PATH variable does not include this folder, users may not be able to find and execute this command line tool. NCHOME is the default installation directory of NCache.
register-ncacheevaluation -key xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -firstname John -lastname Smith -email john@yourdomain.com -registeras developer -company your_company_name
Register NCache with the Purchased License Key
You need to specify the registration type through the registeras
flag when registering a Docker container. The registration types can be Cache Server, Remote Client, or Developer. To do so, use the following command:
register-ncache -key xxxxxxxxx-xxxxxx-xxxxxxxx -environment Production -firstname John -lastname Smith -email john@yourdomain.com -registeras developer -company your_company_name
NCache Docker References
The Dockerfiles provided by NCache at GitHub contain commands to build images for NCache. NCache also provides Dockerfiles and supporting resources on GitHub to allow for more flexibility while using the NCache Docker images. You can use these Dockerfiles to make a customized image based on your dependencies to cater to specific needs.
NCache Docker Tag
NCache offers both Enterprise and Professional edition tags. For instance, for NCache Enterprise, the tag is as follows:
alachisoft/ncache:latest
NCache Dockerfiles
You can use the NCache Dockerfiles to make a customized image with your customized dependencies to cater to your specific needs. You can make these changes within the respective Dockerfiles and build your customized images.
What does NCache Dockerfile contain?
The Dockerfiles provided by NCache at GitHub contain commands to build images for NCache. Before you proceed any further, you need to clone this repo to your local machine and download the NCache setup and place it under the resource folder. Note that to create the image using this Dockerfile, the following resources are required:
- Dockerfile: Dockerfiles can be customized to perform additional tasks.
- NCache Enterprise/Professional setup file: This is a .tar.gz file that can be downloaded from Alachisoft.com.
- installncache.sh: The installncache.sh script extracts the NCache tar.gz and installs NCache at the installation path
/opt
. - ipbinding.sh: The ipbinding.sh script extracts the IP address of the container on the very first usage of container and updates that IP in the NCache configuration files accordingly.
- startup.sh: The startup script calls ipbinding.sh which replaces the IP with the actual IP assigned to the container on the first time the container is started. Furthermore, the startup.sh script starts ncached, and for the Enterprise edition, it also starts the ncacheloaderd and ncachebridged daemon services.
- activate.sh: This script automates the activation of NCache by setting the required environment variables.
These resources must be placed in the following file structure (as also arranged on GitHub). Make sure that the resources folder exists in the same directory as the Dockerfile.
- Dockerfile
- ipbinding.sh, startup.sh, activate.sh, installncache.sh, and ncache setup file in the resources folder.
Customize Dockerfile
You can customize the NCache Dockerfile as per your requirement to perform any additional tasks after or before installation. You can then create your customized images using this Dockerfile and push them to Docker Hub or your local repository. All of this is explained below.
Create Images using Customized Dockerfile
Once you've made your changes to the Dockerfile, follow these steps to create the Docker image:
Navigate to the relative path where the Dockerfile is located. For Windows, this might be something like C:/Docker. Similarly, for Linux, it could be /opt/ncache/.
Run the following command to build the image:
docker build . –t alachisoft/ncache:latest
Important
Similarly, if you want to use the OutProc cache on the client container or you want to monitor NCache Client Counters, you can build the NCache Enterprise Client image using the same process.
Note
To verify that the image has been created, run the command docker images
that lists all images and their details.
Push Image
Once your customized Docker Image(s) has been created, you can push it to a public or local registry using the docker push command. The following command pushes the image ncache with the tag latest to Docker Hub public repository:
docker push alachisoft/ncache:latest
See Also
License Management
Licensing Model
Evaluation Period Management