This guide explains how to create and deploy a Flask app with a Redis database on Unikraft Cloud.
The example consists of two services: a Flask web server that increments a page view counter stored in Redis.
To run this example, follow these steps:
Install the unikraft CLI .
You need a BuildKit builder. The easiest way to get one is via Docker .
Alternatively, you can also directly set up and use BuildKit, see the quick start .
Clone the examples repository and cd into the examples/httpserver-flask-redis directory:
git clone https://github.com/unikraft-cloud/examples
cd examples/httpserver-flask-redis/
Make sure to log into Unikraft Cloud and pick a metro close to you.
This guide uses fra (Frankfurt, 🇩🇪):
Deploy Redis
First, deploy the Redis instance.
Redis is an internal service (not publicly accessible), reached via the redis.internal domain:
unikraft build redis/ --output < my-or g > /redis:latest
unikraft run --metro fra \
-m 256M \
--scale-to-zero policy=idle,cooldown-time=1000,stateful= true \
--domain redis.internal \
--image < my-or g > /redis:latest
The output shows the Redis instance details:
metro : fra
name : redis-09p2q
uuid : 0355f93a-7b60-4ade-9359-b01671e812b3
state : starting
image : <my-org>/redis
resources :
memory : 256MiB
vcpus : 1
service :
uuid : 19c050b2-b5c9-4e8e-9d25-a9053ff09270
name : damp-brook-xmmmwzwo
domains :
- fqdn : redis.internal
networks :
- uuid : 97df34f7-63bc-4f02-a1b4-5ba07278de00
private-ip : 10.0.0.41
mac : 12:b0:0a:00:00:29
timestamps :
created : just now
scale-to-zero : policy=idle,stateful=true,cooldown-time=1s
Deploy Flask
Next, deploy the Flask web server.
It connects to Redis using the REDIS_HOST and REDIS_PORT environment variables:
unikraft build flask/ --output < my-or g > /flask:latest
unikraft run --metro fra \
-m 512M \
-p 443:8000/tls+http \
--scale-to-zero policy=on,cooldown-time= 1000 \
--env REDIS_HOST=redis.internal \
--env REDIS_PORT= 6379 \
--image < my-or g > /flask:latest
The output shows the Flask instance details:
metro : fra
name : flask-q62qa
uuid : d081ec92-629b-45b3-8caf-059e0a87dffd
state : starting
image : <my-org>/flask
runtime :
env :
REDIS_HOST: redis.internal
REDIS_PORT: 6379
resources :
memory : 512MiB
vcpus : 1
service :
uuid : ac1cd90e-a1fe-478c-8f58-8598fa80c494
name : hidden-silence-htyml3s2
domains :
- fqdn : hidden-silence-htyml3s2.fra.unikraft.app
networks :
- uuid : d2f3d024-3082-4e98-be22-f36df84263a1
private-ip : 10.0.0.53
mac : 12:b0:0a:00:00:35
timestamps :
created : just now
scale-to-zero : policy=on,cooldown-time=1s
In this case, the Flask instance address is https://withered-cherry-xfcrfp93.fra.unikraft.app.
It's different for each run.
Test the deployment
Use curl to query the Flask instance.
Each request increments the Redis counter:
curl https://withered-cherry-xfcrfp93.fra.unikraft.app
This webpage has been viewed 1 time(s)
curl https://withered-cherry-xfcrfp93.fra.unikraft.app
This webpage has been viewed 2 time(s)
You can list information about the instances by running:
Clean up
When done, remove the instances:
unikraft instances delete flask-q62qa
unikraft instances delete redis-09p2q
Learn more
Use the --help option for detailed information on using Unikraft Cloud:
Or visit the CLI Reference .
Last modified on October 5, 2026