Zudoku
unikraft

unikraft run

Run an image as an instance.

Code
unikraft run [flags]

Examples

Deploy a new instance and expose a HTTPS service:

TerminalCode
unikraft run --metro=sfo --image=nginx:latest -p 443:8080/http+tls

Deploy a new instance and expose a HTTPS service and redirect from HTTP to HTTPS:

TerminalCode
unikraft run --metro=sfo --image=nginx:latest -p 443:8080/http+tls -p 80:443/http+redirect

Deploy and tail logs from a new instance:

TerminalCode
unikraft run --metro=fra --image=nginx:latest --follow

Preview instance creation without executing:

TerminalCode
unikraft run --metro=dal --image=nginx:latest --dry-run

Deploy a new instance with environment variables:

TerminalCode
unikraft run --metro=was --image=my-app:latest -e KEY1=VALUE1 -e KEY2=VALUE2

Deploy a new instance with attached volume:

TerminalCode
unikraft run --metro=sin --image=my-app:latest -v my-volume:/data

Deploy a new instance with attached volume which is read-only:

TerminalCode
unikraft run --metro=sin --image=my-app:latest -v my-volume:/data:ro

Deploy a new instance with custom resource allocations:

TerminalCode
unikraft run --metro=sfo --image=my-app:latest -m 512MiB --vcpus 2

Deploy a new instance with scale-to-zero enabled:

TerminalCode
unikraft run --metro=fra --image=my-app:latest --scale-to-zero policy=on,cooldown-time=300

Deploy a new instance with specific restart policy:

TerminalCode
unikraft run --metro=dal --image=my-app:latest --restart=on-failure

Deploy a new instance with a configured plugin:

TerminalCode
unikraft run --metro=fra --image=my-app:latest --plugin 'name=sandbox,image=plugins/sandbox:latest,config={"persist_path":"/data"}'

Roll every instance in a service group over to a new image:

TerminalCode
unikraft run --image=my-app:v2 --service=api --rollout

Options

Code
--annotation <key>=<value> Key-value metadata: up to 256 entries with Kubernetes-style [prefix/]name keys. Unlike tags, annotations reach the guest in its start data. --args arg Command-line arguments passed to the instance at start. --autokill <key>=<value> Autokill options. time: time after the instance stops before it is deleted, such as 5s or 24h, 0 disables num-requests: delete the instance after it has served this many requests or connections --autostart Start the instance right after creation. When false it stays stopped, except that scale-to-zero puts it in standby, where incoming traffic starts it. --branch instance Clone an existing instance, by name or UUID. A running source is snapshotted asynchronously and keeps running. Cannot be combined with image, args, env, memory, vcpus, type or gpus. --checkpoint checkpoint Create from a checkpoint, by name or UUID, restoring its memory and disk. Cannot be combined with image, args, env, memory, vcpus, type or gpus. --cmd CMD Run a command to edit fields (receives YAML on stdin, outputs edited YAML on stdout). --domain fqdn Domain for the group. myapp: a bare label becomes a subdomain of the metro example.com: a dotted name is a custom domain, with a certificate issued automatically unless given as fqdn=example.com,certificate=my-cert --dry-run Print patches without applying them. -e, --env <key>=<value> Environment variable as KEY=value. --feature feature Instance feature to enable. delete-on-stop: delete the instance when it stops, not with a restart policy or delete-lock nested-virt: expose virtualization extensions to the guest, needs the nested_virt permission -f, --field FIELD Specify which fields to include in the output. --follow Follow instance logs after creation. --gpus n Number of GPUs to attach, 0 or 1. Requires type full and a plan with GPU support. The instance holds a GPU only while it runs, and gets one of the same model on each start. Cannot be combined with template, branch or checkpoint. --image <name>:<tag> Image to deploy, as an OCI reference or a full registry URL. On create, required unless template, branch or checkpoint is given, and cannot be combined with them. --load LOAD Load fields from a YAML file. -m, --memory size Memory for the instance, within the range the plan allows (see quotas.limits.memory on the metro). Defaults to 128MiB on create. --metro metro Metro to deploy in. Defaults to the profile's default metro. -n, --name name Instance name, unique per metro. Generated when omitted. --network <key>=<value> Network interface to attach, one per flag and up to 4. The first one is the primary interface. Needs the net_manager permission. name: interface name, unique in the account. Set it on a relay, so that other instances can refer to it. While its clients run, the relay instance stops only with --force and cannot be deleted relay.name: name of the interface, not of the instance, that gets all the traffic of this one. It must be a platform interface of another instance, with no relay of its own relay.uuid: the same, by UUID relay.dns: false sends DNS requests to the platform's DNS server instead of the relay (default true) tap-name: host TAP device, to bring your own interface ip: address in CIDR notation, needs tap-name mac: unicast MAC address, needs tap-name autoconfig: whether the platform configures the interface inside the guest --node node Node to place the instance on. -o, --output OUTPUT Output format. One of: kv, table, json, yaml, raw, quiet, template. --plugin name=<name>,image=<ref>[,config=<json>] Plugin loaded from an image, with an optional JSON config passed to it on start. Up to 8 per instance. -p, --publish <src>:<dest>[/<handlers>] Published port as SOURCE:DESTINATION[/HANDLERS], with handlers joined by +. Port 80 must use http, port 443 http+tls, and any other port tls only. http: load balance per HTTP request instead of per TCP connection tls: terminate TLS at the platform redirect: redirect HTTP on port 80 to HTTPS, as in 80:443/http+redirect --pull-policy policy When to pull the image relative to the node's cache: always, if_not_present or never. --replicas n Additional identical instances to create, so replicas=2 creates three in total. --restart policy Restart policy. Restarts back off from immediate up to 5m. Cannot be combined with the delete-on-stop feature. never: never restart (default) always: restart whenever the instance exits or crashes on-failure: restart only after a crash or a non-zero exit code --rm Automatically delete the instance when it stops. --rollout <key>=<value> Replace every instance the rollout selects with a new one and delete the old ones. Requires --autostart. type: rolling (default) | recreate by: service (default) | tags target: the new instance's service, or a subset of its tags, to select by (default: all of them) batch: instances that a rolling rollout replaces at a time (default: 1) healthy-after: time each new batch must keep running before the rollout goes on --rom name=<name>,image=<ref>,at=<path> Read-only ROM device from an image or a local directory. The name uses letters, digits, - and _, and appears as /dev/ukp_rom_NAME in the guest. --save FILE Save creatable fields as YAML to a file (use - for stdout). --scale-to-zero <key>=<value> Scale-to-zero options. Traffic through a service or to the private IP wakes the instance. policy: on | idle (also while open TCP connections are idle, needs stateful=true) | off cooldown-time: ms of inactivity before scaling to zero notify-time: ms the instance is warned beforehand, 0 disables and the value must be below cooldown-time stateful: true keeps RAM in a snapshot and resumes from it, false restarts from scratch --sched-priority priority Scheduling priority: normal (default), medium, high or admin. Requires the override_vm_priority permission. --service name Service group to join, by name or UUID. Leave unset and give service.services or service.domains to create a group owned by the instance. Without any service the instance is reachable only privately. --set <name>=<value> Key-value pairs to set on the instance. --set-file <name>=<filename> Files containing key-value pairs to set on the instance. --tag tag Tags for grouping and filtering: up to 16, each 1 to 256 characters of letters, digits and -+_.:=. Not visible to the guest. --template name Create from an instance template, by name or UUID. The clone inherits its configuration and, when the template has a snapshot, its memory state. Cannot be combined with image, branch, checkpoint, type or gpus. --type type Virtual machine type. micro: Firecracker microVM (default) full: QEMU virtual machine with GPU support, needs a plan with full VM support and has no branching, checkpoints, vertical scaling, annotations or virtiofs volumes --vcpus n Number of vCPUs, within the range the plan allows (see quotas.limits.vcpus on the metro). Defaults to 1 on create. --visual Open an editor to modify fields visually. -v, --volume [<name>]:<path>[:<options>] Volume to attach as NAME:/MOUNT[:ro], where the mount path is absolute and outside /uk. On create, leave NAME empty and add :size=SIZE, as in :/data:size=1GiB, to make a new volume with a generated name.

Options inherited from parent commands

Code
--config file Path to the configuration file. --log-level level Set the logging level. (default info) --log-type type Set the log type. (default text) --profile name Set the current profile. --telemetry Toggle usage analytics. (default true) --timeout duration Set a deadline for the command (e.g. 30s, 5m, 1h).

See Also

  • unikraft: The Unikraft Command-Line Interface.
Last modified on