### CLI: krunvm start Source: https://github.com/containers/krunvm/blob/main/docs/krunvm-start.1.txt Starts an existing microVM created by krunvm-create, allowing for optional configuration overrides and command execution. ```APIDOC ## CLI: krunvm start ### Description Starts an existing microVM created by krunvm-create(1) and attaches stdin/stdout to its virtio-console. ### Method CLI Command ### Endpoint krunvm start [OPTIONS] microVM [COMMAND] [-- ARGS] ### Parameters #### Path Parameters - **microVM** (string) - Required - The name or identifier of the microVM to start. #### Options - **--cpus** (NUM) - Optional - Override the number of vCPUs configured for this microVM. - **--mem** (NUM) - Optional - Override amount of RAM, in MiB, configured for this microVM. - **--env** (KEY=VALUE) - Optional - Set environment variable to be passed to the microVM. ### Request Example krunvm start my-vm --cpus 2 --mem 1024 --env DEBUG=1 -- /bin/sh ``` -------------------------------- ### Install krunvm on Fedora Source: https://github.com/containers/krunvm/blob/main/README.md Install krunvm on Fedora by enabling necessary COPR repositories and then installing the package using DNF. ```bash dnf copr enable -y slp/libkrunfw dnf copr enable -y slp/libkrun dnf copr enable -y slp/krunvm dnf install -y krunvm ``` -------------------------------- ### Install krunvm on macOS Source: https://context7.com/containers/krunvm/llms.txt Use Homebrew to tap the krun repository and install the krunvm binary. ```bash # Tap the krun repository and install krunvm brew tap slp/krun brew install krunvm ``` -------------------------------- ### Start a microVM with custom configurations Source: https://context7.com/containers/krunvm/llms.txt Override default CPU and memory settings or pass environment variables to the containerized process. ```bash krunvm start fedora-dev /bin/bash --cpus 4 ``` ```bash krunvm start fedora-dev /bin/bash --mem 4096 ``` ```bash krunvm start python-dev /usr/local/bin/python -- /workspace/app.py \ --env PYTHONPATH=/workspace \ --env DATABASE_URL=localhost:5432 ``` ```bash krunvm start node-app /bin/sh ``` -------------------------------- ### Start MicroVMs Source: https://context7.com/containers/krunvm/llms.txt Launch a microVM and optionally execute commands or set environment variables. ```bash # Start a microVM and run its default entrypoint krunvm start my-ubuntu # Start a microVM and run a specific shell krunvm start my-ubuntu /bin/bash # Start a microVM and run a command with arguments krunvm start my-ubuntu /bin/cat -- /etc/os-release # Start with environment variables krunvm start python-dev /usr/local/bin/python --env DEBUG=true --env PORT=8000 ``` -------------------------------- ### Install krunvm on macOS Source: https://github.com/containers/krunvm/blob/main/README.md Use Homebrew to install krunvm on macOS. Ensure the slp/krun tap is added first. ```bash brew tap slp/krun brew install krunvm ``` -------------------------------- ### GET /krunvm/list Source: https://github.com/containers/krunvm/blob/main/docs/krunvm-list.1.txt Lists all microVMs created by krunvm-create that have not been removed by krunvm-delete. ```APIDOC ## GET /krunvm/list ### Description Lists the existing microVMs created by krunvm-create that have not been removed by krunvm-delete. ### Method GET ### Endpoint /krunvm/list ``` -------------------------------- ### Build krunvm from Sources Source: https://github.com/containers/krunvm/blob/main/README.md Build krunvm from its source code using Cargo. Ensure Rust toolchain, libkrun, buildah, and asciidoctor are installed as dependencies. ```bash cargo build --release ``` -------------------------------- ### Build krunvm from Source Source: https://context7.com/containers/krunvm/llms.txt Clone the repository and compile the project using Cargo. ```bash # Clone the repository and build git clone https://github.com/containers/krunvm cd krunvm cargo build --release ``` -------------------------------- ### Manage krunvm Global Configuration Source: https://context7.com/containers/krunvm/llms.txt View or update default settings for CPU, RAM, and DNS for new microVMs. ```bash # View current global configuration krunvm config # Output: # Global configuration: # Default number of CPUs for newly created VMs: 2 # Default amount of RAM (MiB) for newly created VMs: 1024 # Default DNS server for newly created VMs: 1.1.1.1 # Set default number of vCPUs for new microVMs (max 8) krunvm config --cpus 4 # Set default RAM in MiB for new microVMs (max 16384) krunvm config --mem 2048 # Set default DNS server for new microVMs krunvm config --dns 8.8.8.8 # Configure all defaults at once krunvm config --cpus 4 --mem 4096 --dns 1.1.1.1 ``` -------------------------------- ### Create MicroVMs Source: https://context7.com/containers/krunvm/llms.txt Create and configure microVMs from OCI images with options for resources, volumes, and networking. ```bash # Create a basic microVM from an Alpine image with default settings krunvm create docker.io/library/alpine:latest # Create a microVM with a custom name, 2 vCPUs, and 1024 MiB RAM krunvm create docker.io/library/ubuntu:22.04 --name my-ubuntu --cpus 2 --mem 1024 # Create a microVM with volume mappings (host_path:guest_path) krunvm create docker.io/library/fedora:38 \ --name fedora-dev \ -v /home/user/projects:/projects \ -v /home/user/data:/data # Create a microVM with port mappings (host_port:guest_port) krunvm create docker.io/library/nginx:latest \ --name webserver \ --port 8080:80 \ --port 8443:443 # Create a microVM with a custom working directory krunvm create docker.io/library/node:18 \ --name node-app \ --workdir /app \ -v /home/user/myapp:/app # Create a fully configured microVM with all options krunvm create docker.io/library/python:3.11 \ --name python-dev \ --cpus 4 \ --mem 2048 \ --dns 8.8.8.8 \ --workdir /workspace \ -v /home/user/code:/workspace \ --port 5000:5000 # On macOS ARM64: Create an x86_64 microVM using Rosetta (limited to 1 CPU) krunvm create docker.io/library/debian:latest --name x86-debian --x86 ``` -------------------------------- ### krunvm create Source: https://github.com/containers/krunvm/blob/main/docs/krunvm-create.1.txt Creates a new microVM from an OCI image with configurable hardware and environment settings. ```APIDOC ## krunvm create ### Description Creates a new microVM from the OCI image specified by IMAGE. ### Method CLI Command ### Endpoint krunvm create [OPTIONS] IMAGE ### Parameters #### Path Parameters - **IMAGE** (string) - Required - The OCI image to use for the microVM. #### Options - **--cpus** (NUM) - Optional - The number of vCPUs for the microVM. - **--mem** (NUM) - Optional - The amount of RAM in MiB available to the microVM. - **--name** (NAME) - Optional - The name to be assigned to the microVM. - **-p, --port** (HOST_PORT:GUEST_PORT) - Optional - Exposes a guest port through a host port. Can be specified multiple times. - **-v, --volume** (HOST_PATH:GUEST_PATH) - Optional - Maps a host path to a guest path. Can be specified multiple times. - **-w, --workdir** (GUEST_PATH) - Optional - Sets the working directory for the first binary executed in the microVM. ``` -------------------------------- ### List MicroVMs Source: https://context7.com/containers/krunvm/llms.txt Display status and configuration details for all created microVMs. ```bash # List all existing microVMs krunvm list # Example output: # my-ubuntu # CPUs: 2 # RAM (MiB): 1024 # DNS server: 1.1.1.1 # Buildah container: ubuntu-working-container # Workdir: /root # Mapped volumes: {} # Mapped ports: {} # # webserver # CPUs: 2 # RAM (MiB): 1024 # DNS server: 1.1.1.1 # Buildah container: nginx-working-container # Workdir: # Mapped volumes: {} # Mapped ports: {"8080": "80", "8443": "443"} ``` -------------------------------- ### Configure Linux user namespace Source: https://context7.com/containers/krunvm/llms.txt Use buildah unshare to handle user namespaces when running as a non-root user on Linux. ```bash buildah unshare krunvm create docker.io/library/alpine:latest --name my-alpine ``` ```bash buildah unshare # Now inside the unshare session: krunvm create docker.io/library/alpine:latest --name my-alpine krunvm start my-alpine /bin/sh krunvm delete my-alpine exit ``` -------------------------------- ### POST /changevm Source: https://github.com/containers/krunvm/blob/main/docs/krunvm-changevm.1.txt Modifies the configuration of an existing microVM or displays current settings if no options are provided. ```APIDOC ## POST /changevm ### Description Changes the configuration of an existing microVM. When run without options, it displays the current configuration. ### Method POST ### Endpoint /changevm ### Parameters #### Query Parameters - **microVM** (string) - Required - The identifier of the microVM to modify. - **--remove-ports** (flag) - Optional - Removes all port mappings. - **--remote-volumes** (flag) - Optional - Removes all volume mappings. - **--cpus** (integer) - Optional - Changes the number of vCPUs. - **--mem** (integer) - Optional - Changes the amount of RAM in MiB. - **--name** (string) - Optional - Assigns a new name to the microVM. - **-p, --port** (string) - Optional - Exposes a port (format: HOST_PORT:GUEST_PORT). Can be specified multiple times. - **-v, --volume** (string) - Optional - Maps a host path to a guest path (format: HOST_PATH:GUEST_PATH). Can be specified multiple times. - **-w, --workdir** (string) - Optional - Configures the working directory for the first binary executed. ``` -------------------------------- ### krunvm delete Source: https://github.com/containers/krunvm/blob/main/docs/krunvm-delete.1.txt Deletes an existing microVM configuration and requests buildah to unmount and remove the OCI image backing it. ```APIDOC ## DELETE /containers/krunvm/{microVM} ### Description Deletes an existing microVM configuration and requests buildah to unmount and remove the OCI image that was backing it. ### Method DELETE ### Endpoint /containers/krunvm/{microVM} ### Parameters #### Path Parameters - **microVM** (string) - Required - The name or ID of the microVM to delete. ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the microVM was deleted. #### Error Response (404) - **error** (string) - Message indicating the microVM was not found. ``` -------------------------------- ### Configure macOS APFS volume Source: https://context7.com/containers/krunvm/llms.txt Set up a case-sensitive APFS volume required for storing container images on macOS. ```bash diskutil apfs addVolume disk3 "Case-sensitive APFS" krunvm ``` ```bash krunvm create docker.io/library/alpine:latest ``` -------------------------------- ### Modify microVM configuration Source: https://context7.com/containers/krunvm/llms.txt Update CPU, memory, name, volumes, ports, or working directory for an existing microVM. ```bash krunvm changevm my-ubuntu ``` ```bash krunvm changevm my-ubuntu --cpus 4 ``` ```bash krunvm changevm my-ubuntu --mem 4096 ``` ```bash krunvm changevm my-ubuntu --new-name ubuntu-server ``` ```bash krunvm changevm python-dev --workdir /app ``` ```bash krunvm changevm python-dev \ -v /home/user/newproject:/project \ -v /home/user/config:/config ``` ```bash krunvm changevm python-dev --remove-volumes ``` ```bash krunvm changevm webserver \ --port 80:80 \ --port 443:443 \ --port 8080:8080 ``` ```bash krunvm changevm webserver --remove-ports ``` ```bash krunvm changevm my-vm \ --new-name production-vm \ --cpus 8 \ --mem 8192 \ --workdir /app \ -v /data:/data \ --port 3000:3000 ``` -------------------------------- ### Delete a microVM Source: https://context7.com/containers/krunvm/llms.txt Permanently remove a microVM configuration and its backing OCI image. ```bash krunvm delete my-ubuntu ``` ```bash krunvm create docker.io/library/alpine:latest --name temp-vm krunvm start temp-vm /bin/sh # ... do some work ... krunvm delete temp-vm ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.