Skip to content

Voyrox/Qube

Repository files navigation

GitHub contributors Github CI

Features

  • Lightweight and fast container runtime.
  • Written in Rust for memory safety and performance.
  • Supports basic container isolation using Linux namespaces.

Motivation

Qube aims to provide a lightweight, secure, and efficient container runtime. Rust's memory safety and performance make it an ideal choice for implementing container runtimes. Qube is designed to be simple yet powerful, with a focus on extensibility and security.

🚀 Quick Start

Tip

You can immediately set up your environment with youki on GitHub Codespaces and try it out.

Open in GitHub Codespaces

$ cargo build --release
$ sudo ln -s /mnt/e/Github/Qube/target/release/Qube /usr/local/bin/Qube
$ cp qubed.service /etc/systemd/system/qubed.service
$ systemctl daemon-reload

📍 Status of Qube

Manage Containers

  • Run a container

    Prebuilt Images

    • Ubuntu24_Multi: A multi-purpose Ubuntu 24.04 container with Node.js, Rust, and Python3 pre-installed.
    • Ubuntu24_NODE: A Node.js container based on Ubuntu 24.04.
    • Ubuntu24_RUST: A Rust container based on Ubuntu 24.04.
    • Ubuntu24_PYTHON: A Python3 container based on Ubuntu 24.04.
    • Ubuntu24_GOLANG: A Go container based on Ubuntu 24.04.
    • Ubuntu24_JAVA: A Java container based on Ubuntu 24.04.

    Registers a container (with a placeholder PID) and starts it automatically via the daemon. | Add --isolation to disable the network namespace.

    sudo Qube run --image Ubuntu24_Multi -cmd "<cmd>"
    # e.g.
    sudo Qube run --image Ubuntu24_NODE --ports 3000 --cmd "npm i && node index.js"

    QML File

    The QML file is used to define the configuration and behavior of your containers. It allows you to specify various settings such as the container's name, image, command, ports, and more. Here is an example of a QML file:

    container:
      # The base system image to use for the container.
      system: Ubuntu24_NODE
    
      # Ports to be exposed by the container.
      ports:
        - "3000"
    
      # Command to run inside the container.
      cmd:
        - npm install
        - node index.js
    
      # Optional: Enable network isolation for the container.
      isolated: false
    
      # Optopnal: Add Enviromental variables to the container.
      enviroment:
        - SUPER_TOKEN = "1234567890abcdefghijklmnopqrstuvwxyz"
    
      # Optional: Volumes to mount into the container.
      volumes:
        - host_path: "/path/on/host"
          container_path: "/path/in/container"
    
      # Optional: Enable debug mode for more verbose output.
      debug: false

    To use the QML file, you need to run the run command in the same directory as the QML file. The run command will automatically detect the QML file and use it to create the container.

    sudo Qube run
  • List running containers

    Displays all tracked containers, along with their PIDs, uptime, and status.

    sudo Qube list
  • Stop a container Immediately Stops a container by sending it a SIGKILL.

    sudo Qube stop <pid|container_name>
  • Start a container Starts a stopped container.

    sudo Qube start <pid|container_name>
  • Eval a container

    Allows you to attach to a container (by name or PID) and run commands as root inside it. WARNING: Running commands as root inside a container may alter its configuration and pose security risks. Use with caution!

    # Launch an interactive shell in the container:
    sudo Qube eval <container_name|pid>
    
    # Execute a specific command as root in the container:
    sudo Qube eval <container_name|pid> [command]
  • View container info Shows detailed information about a container, such as its name, PID, working directory, command, timestamp, and uptime.

    sudo Qube info <container_name|pid>
  • Snapshot a container Creates a snapshot (a compressed tarball) of the container’s filesystem. The snapshot is stored in the container's working directory.

    sudo Qube snapshot <container_name|pid>

Custom Images 📦

  • Create a custom image Creates a custom image from a container. The image is stored in the images directory.

    Default Image

    • Node.js
    • Rust
    • Python3

    Options

    • INSTALL_NODE=true Install Node.js and npm.
    • INSTALL_RUST=true Install Rust.
    • INSTALL_PYTHON=true Install Python.
    • INSTALL_GOLANG=true Install Go.
    • INSTALL_JAVA=true Install Java.
    INSTALL_<NAME> ./buildIMG/install_and_pack.sh

Dependencies

Install the required dependencies:

sudo apt-get install -y build-essential libseccomp-dev libssl-dev tar

Setup

To create a root filesystem for your container:

sudo apt-get install -y debootstrap

sudo debootstrap \
    --variant=minbase \
    jammy \
    /tmp/ubuntu24rootfs \
    http://archive.ubuntu.com/ubuntu/

sudo tar -C /tmp/ubuntu24rootfs -cf ubuntu24rootfs.tar .

Dev Notes

Building the Docs Site

bundle install
bundle exec jekyll serve

Roadmap

  • Resource Limiting: Add support for limiting CPU, memory, and disk usage. sudo Qube run --image Ubuntu24_Multi --cpu 2 --memory 512M --cmd "npm i && node index.js"
  • Restore: Allow users to save the state of a container and revert to it later. sudo Qube snapshot restore <snapshot_id> | sudo Qube snapshot create <container_name|pid>
  • Rootless Containers: Add CLONE_NEWUSER and map UID/GIDs to avoid requiring sudo.
  • Security: Integrate seccomp, capabilities, and AppArmor/SELinux for enhanced security.

Contributing

Your ideas and contributions are welcome! Feel free to open issues or submit pull requests.