Skip to content

Latest commit

 

History

History
64 lines (42 loc) · 1.92 KB

File metadata and controls

64 lines (42 loc) · 1.92 KB

Ruby Web Server

This directory contains a Ruby web 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
zealous_ramu  oci://unikraft.org/ruby:3.4  /usr/bin/ruby /src/server.rb  14 minutes ago  running  488M  0.0.0.0:8080->8080/tcp  qemu/x86_64

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

kraft rm zealous_ramu

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