Cache Dockerfile for Linux
NCache also provides Dockerfiles and supporting resources on GitHub to allow more flexibility while using the NCache Docker image. You can use these Dockerfiles to make a customized image with your customized dependencies to cater to your specific needs. For example, you want to change the Linux distro from Ubuntu to Mint, you can make this change in the NCache Dockerfile and build a customized image.
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 Dockerfiles for linux are placed at GitHub for the following:
NCache Enterprise .NET Core 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
.You can get the installncache.sh scripts from GitHub for the following:
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.
You can get the ipbinding.sh scripts from GitHub for the following:
Important
In case dynamic IPs have been assigned, the container might be assigned a new IP address (on container or host restart) instead of the one stored in the configuration during container creation. This results in NCache service not starting.
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, ncacheloaderd and ncachebridged daemon services.
You can get the startup.sh scripts from GitHub for the following editions:
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, installncache.sh, and ncache setup file in the resource 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
Using your customized Dockerfile, you can now create Docker images that 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 /opt/ncache/.
The following docker build command creates image
ncache
with optional tag enterprise-server-linux-latest in the format <image_name>:<optional_tag>:
PS /opt/ncache/Docker> docker build . –t alachisoft/ncache:latest-java
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 alachisoft/ncache:latest-java to Docker Hub public repository:
docker push alachisoft/ncache:latest-java
See Also
Create Containers in Linux NCache Docker on Linux NCache Docker on Windows