Nodegrid Docker Container

Nodegrid Docker Container

Nodegrid linux distribution have docker application pre-installed.
Verification can be done with "docker --version" command in the root shell of the Nodegrid.


Note: Nodegrid requires licensing to enabled to run the containers in Nodegrid appliance

In this example, using express to service the webpage within the Nodegrid.  Since the Nodegrid is using the 443 port for the Nodegrid Manager application, the express page will be using the port 4000 for web service.
For this container to run, Node is required in the Linux disctribution.  using command "node --version" to determined if Node is in the system.




Step 1: from the Nodegrid root shell, create a folder for the container.  example "mkdir testexpress".  Go into the created folder "cd testexpress"
Step 2: execute "npm install" from within the folder.  This command will create package.json file
Step 3: execute "npm install --package-lock" will generate package-lock.json file

  1. The package.json should have:
  2. {
  3.   "name": "testDock",
  4.   "version": "1.0.0",
  5.   "description": "",
  6.   "main": "index.js",
  7.   "scripts": {
  8.     "test": "echo \"Error: no test specified\" && exit 1"
  9.   },
  10.   "keywords": [],
  11.   "author": "",
  12.   "license": "ISC",
  13.   "dependencies": {
  14.     "express": "^4.17.1"
  15.   }
  16. }

The package-lock.json should be left as is.

Step 4: Create a folder "mkdir src" inside of the example "testexpress" folder.
Step 5: Create "server.js" file in the testexpress/src folder. The server.js contains
  1. {
  2.   "name": "testDock",
  3.   "version": "1.0.0",
  4.   "description": "",
  5.   "main": "src/server.js",
  6.   "scripts": {
  7.     "start": "node src/server.js"
  8.   },
  9.   "keywords": [],
  10.   "author": "Son Nguyen",
  11.   "license": "ISC"
  12. }

Step 6: Create a file "app.js" in the "testexpress/src" folder. The app.js contains
  1. const express = require('express')
  2. const app = express()
  3. app.get('/', (req, res) => res.send('Hello World! This is Son Test'))
  4. app.listen(4000, () => console.log('Server ready'))

Step 7: Build this docker image and register it to docker
  1. docker build -t appname:tagname dir
For this example: "docker build -t testexpress:1.0 ." can be used to create this docker image.
The build process can take up to a few minutes.  Example output

Step 8: "docker images" command be used to see the images registered in docker.

Step 9: The images is now in docker to run this image
  1. docker run -d -p 4000:4000 testexpress:1.0 .
The -d option is to detached the current shell from the executed container.
The -p option is port exposed in the Dockerfile to access the webpage this container is servicing

Step 10: using the "docker ps -a" to see all the current running containers





Step 11: The container is currently running, to access the container webpage, open a browser with "http://<nodegrid management ip>:4000
The results showed the container express web service replied

Step 12: Stopping the container with "docker stop <CONTAINER ID>".  Use the "docker ps -a" to get the container id

Step 13: The container can be removed from docker "docker rmi -f <image id>".  The image id can be retrieved from the "docker images" command








    • Related Articles

    • Docker container exits and stops running

      Nodegrid supports docker virtualization and to run docker you require a license. All you need is to install the license and activate the docker in Nodegrid. If the license is not installed on the device, docker might not run at all or container would ...
    • Licensing and activating Docker virtualization

      The Nodegrid platform allows administrators to run Docker applications. To work in Docker, one needs a license that must be installed in Nodegrid. Follow this steps to run docker in Nodegrid, Login in as admin in WebUI Go to System and navigate to ...
    • Customize docker data-root from Nodegrid UI

      In Nodegrid 6.0 or greater, you can customize the docker data-root from the Web UI. You can specify which disk partition to move the docker data-root. Any mounted and formatted disk partition can be used. The location will be created as /docker. If ...
    • Nodegrid Docker license and virtualization

      The Nodegrid platform allows administrators to run Docker applications. The platform allows pulling of Docker applications from Docker Hub, starting and stopping of the Docker Containers. The management of Docker Applications is currently only ...
    • Nodegrid and Docker

      To use Docker with Nodegrid, you need to enable the service and add a Docker license. If you don't have a Docker license for Nodegrid OS, you can reach out to your account manager or contact support@zpeystems.com. Without a Docker license, your ...