Troubleshooting
This guide explains how to debug apps on Unikraft Cloud so you can fix issues or collect enough information for the support team to help you. It follows platform best practices and supports efficient troubleshooting. If you need help, reach out to Unikraft Cloud Support on Discord or write to support@unikraft.cloud.
Debugging running apps
The most direct way to debug an app is to use the app console output, which may include kernel output. To see it, after starting the Unikraft Cloud instance, use:
Code
In case of a crash, you'll see a full crash output:
Code
or even
Code
Inspect the instance details to see the stop reason:
Code
This yields output like:
Code
This output shows the stop reason. Here the cause is insufficient memory.
If the stop reason lacks detail, enable debug tracing for the instance.
To do that, pick an app from the examples repository or an app directory you created.
Update the runtime entry in the Kraftfile to reference the debug build by adding -dbg to the runtime name.
For example, if you want to run the httpserver-go1.21 example with debug output, update its Kraftfile as follows:
Code
That is, change base-compat:latest to base-compat:latest-dbg.
Now you're ready to re-deploy:
Code
You can now inspect the logs as before and view system call tracing:
Code
This mechanism works for all apps and runtimes. Contact Unikraft Cloud on the Discord server and include this output if you need more detail.
While you debug an issue you can mitigate crashes by setting a restart policy.
For example, use the CLI to set --restart on-failure so the platform restarts the app if it crashes.
Code
Debugging the build and push steps
The CLI performs steps on your local device before actually deploying your app to Unikraft Cloud:
- Downloads the runtime image (defined in the
Kraftfile) from the Unikraft Cloud registry. - Builds the app filesystem using the
Dockerfilevia BuildKit. - Packages the app filesystem and the runtime in an Open Container Initiative (OCI) image.
- Pushes the OCI image to the to the Unikraft Cloud registry under your username's namespace.
If any of these steps fail, enable CLI debugging with the --log-level and --log-type flags:
Code
You should then see debug output for the 4 steps above. This output should give enough context to diagnose the issue.
Caching the app's filesystem for faster builds
When using a Dockerfile for the app filesystem, Unikraft Cloud passes the commands to BuildKit.
The unikraft CLI uses the first BuildKit builder that it finds, in this order:
- The builder at the address in the
BUILDKIT_HOSTenvironment variable. - The builder on the default BuildKit socket.
- The builder in Docker.
The builder keeps its cache between builds.
To control where the cache stays, start a BuildKit container and set BUILDKIT_HOST to its address:
Code
The approach above caches builds in the BuildKit container filesystem. Another approach saves the cache in a local host directory:
Code
Here $HOME/.buildkit-cache is a local path on your machine where BuildKit stores cache data.
Large filesystem build process gets stuck
When the filesystem is larger than about 800 MB, the build may get stuck.
A limitation in BuildKit, the current filesystem build component, causes the issue.
Work around this by reducing the filesystem image below 800 MB.
Work is in progress to integrate a component without this limitation.
Gateway error when accessing a service
When you query a Unikraft Cloud service via its public address, such as:
Code
you may get a Bad Gateway response:
Code
This happens when you specify the wrong internal app port (for example, the app exposes port 8080 but you use 443:80 instead of 443:8080).
Another error response you may get is:
Code
This happens when you connect with an HTTPS client (port 443) and the app doesn't expose that port.
Database services such as MongoDB or MariaDB use different ports (for example, 27017, 3306).
Use the correct exposed port. You may need a TLS tunnel (see below).
If you still have issues, it might mean that the app fails to start or crashes immediately. In that case, inspect the app logs first.
Connecting to a non-TLS app
Unikraft Cloud uses TLS to expose services to the outside world. Some apps (such as MongoDB or MariaDB) don't use TLS.
Create a TLS tunnel with the unikraft instances tunnel command or with socat.
Both open a local endpoint (localhost / 127.0.0.1) and forward the traffic over TLS.
See the MariaDB guide for an example.
Launched app not visible in list
The most common reason is that you deployed an app to one metro but listed a different one.
Use the --metro flag to select the metro for each command:
Code
Learn more
- The CLI reference.
- Unikraft Cloud's REST API reference.
- Many more guides here.