Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

NodeJS 18 HTTP Web Server

This directory contains a Node HTTP server running on Unikraft.

Set Up

To run this example, install Unikraft's companion command-line toolchain kraft, clone this repository and cd into this directory.

Run and Use

Use kraft to run the image and start a Unikraft instance:

kraft run --rm -p 8080:8080 --plat qemu --arch x86_64 -M 512M .

If the --plat argument is left out, it defaults to qemu. If the --arch argument is left out, it defaults to your system's CPU architecture.

Once executed, it will open port 8080 and wait for connections. To test it, you can use curl:

curl localhost:8080

You should see a "Bye, World!" message.

Inspect and Close

To list information about the Unikraft instance, use:

kraft ps
NAME           KERNEL                      ARGS                              CREATED         STATUS   MEM   PORTS                   PLAT
vigorous_loon  oci://unikraft.org/node:18  /usr/bin/node /usr/src/server.js  18 seconds ago  running  488M  0.0.0.0:8080->8080/tcp  qemu/x86_64

The instance name is vigorous_loon. To close the Unikraft instance, close the kraft process (e.g., via Ctrl+c) or run:

kraft rm vigorous_loon

Note that depending on how you modify this example your instance may need more memory to run. To do so, use the kraft run's -M flag, for example:

kraft run --rm -p 8080:8080 --plat qemu --arch x86_64 -M 1024M .

kraft and sudo

Mixing invocations of kraft and sudo can lead to unexpected behavior. Read more about how to start kraft without sudo at https://unikraft.org/sudoless.

Learn More