Skip to content

Build and run a container

unitexe edited this page Feb 5, 2025 · 3 revisions

Overview

Build and run an amd64 OCI container, the app-container flask app provided by meta-virtualization specifically.

Activate python virtual environment

source ~/.venv.yocto/bin/activate

Configure

Configure the build, work, sstate and download directories based on the distro, machine and release.

export KAS_CONTAINER_ENGINE=podman
export KAS_BUILD_DIR="/home/$(whoami)/dev/yocto/unit/build/styhead/pokyless/amd64-container/"
export KAS_WORK_DIR=$KAS_BUILD_DIR
export SSTATE_DIR="/home/$(whoami)/dev/yocto/unit/build/styhead/sstate/"
export DL_DIR="/home/$(whoami)/dev/yocto/unit/dl"
  • Could replace pokyless with rocky here if we want musl

Build

kas-container build images/pokyless/amd64-container/app-container/scarthgap.yml

Load

Position at root of build directory.

cd $KAS_BUILD_DIR

Load image.

podman load -i tmp/deploy/images/amd64-container/app-container-latest-oci.tar

Run

podman run -dt -p 8080:9000/tcp localhost/latest:latest

Test

Send a get request to the oe endpoint, this will output Hello from OpenEmbedded!.

curl http://localhost:8080/oe/ && echo

Send a get request to the yocto endpoint, this will output Hello from Yocto!.

curl http://localhost:8080/yocto/ && echo

Cleanup

Stop container.

podman stop -l

Remove container.

podman rm -l

Remove image.

podman image rm localhost/latest:latest
Clone this wiki locally