This guide shows how to build and run a lightweight Docker container for AMD-Xilinx PetaLinux 2024.2 development on Kria SOM boards. The container includes all necessary dependencies, maps the tools from your host system, and provides a persistent workspace. This setup avoids polluting your host environment while remaining flexible and reproducible.
Why Docker?Installing PetaLinux 2024.2 directly on a modern Ubuntu 24.04.2 LTS system — especially one already configured with Vivado and Vitis — can be problematic. Conflicting dependencies, required legacy libraries, or incompatible tool versions often lead to a frustrating setup process.
I ran into exactly these kinds of issues and realized that trying to align all toolchains on a single host OS was both error-prone and time-consuming.
That’s why I chose Docker. It provides:
- A clean, isolated environment for PetaLinux tools.
- Reproducibility: no more “it works on my machine” problems.
- Compatibility: the container mimics the officially supported OS, regardless of what runs on the host.
- Portability: run it on any Linux system with Docker installed.
This tutorial is for developers like me who want to get started with PetaLinux on Kria boards without breaking their existing setup or wasting hours resolving package conflicts.
Requirements- A Linux host system (Ubuntu 20.04, 22.04 or 24.04.2 recommended)
- Docker-Engine installed
- PetaLinux 2024.2 installation file downloaded on your host machine
- Basic understanding of terminal commands
Before using Docker for PetaLinux development, you need to configure your host system to allow non-root users to run containers with root-like privileges. This is especially important for enabling features like accessing devices within the container.
Enable Unprivileged User Namespaces
Some Linux systems restrict unprivileged user namespaces by default, which can cause issues when running certain tools inside Docker. To avoid permission problems, especially with PetaLinux
, you need to relax AppArmor restrictions.
- Create a new
sysctl
configuration file:
sudo vi /etc/sysctl.d/99-petalinux.conf
- Add the following line to the file:
kernel.apparmor_restrict_unprivileged_userns = 0
- Apply the new setting:
sudo sysctl --system
This allows Docker containers to safely use user namespaces with fewer restrictions, ensuring smoother operation of development tools inside the container.
Install Docker Engine
Begin by installing Docker Engine on your system by following the official instructions provided here.
Make sure Docker is working by running:
docker --version
Step-1: Prepare the Directory StructureCreate a working folder for this project and download the following three files from the Attachments section into it:
Dockerfile
- your Docker configurationbuild.sh
- to build the Docker imagerun.sh
- to launch the container
Directory layout:
kria-petalinux/
├── Dockerfile
├── build.sh
├── run.sh
├── workspace/ # Will be used by the container as your working directory
Prepare the Installation Directory
Create a directory where PetaLinux will be installed:
mkdir -p /tools/petaLinux/2024.2
This directory will be mounted inside the container later and used as the installation target.
Download the petalinux-v2024.2-11062026-installer.run file and place it in the /tools
directory so it’s accessible from within the Docker container during installation.
Go to the previously created kria-petalinux
directory, make the build.sh
script executable and run it:
chmod +x *.sh
./build.sh
This will build a Docker image named petalinux-2024.2:kria
with all dependencies and a user-mapped environment for safe file access.
This project includes a purpose-built Dockerfile that creates a fully isolated and reproducible PetaLinux development environment tailored for AMD/Xilinx Kria SOMs. The container is based on Ubuntu 22.04 LTS and includes all required dependencies for PetaLinux tools, along with helpful utilities like git
, tmux
, vim
, and a lightweight TFTP server (tftpd-hpa
) for U-Boot network booting.
Key features include:
- Pre-installed development tools and libraries required for PetaLinux workflows.
- Locale and shell setup to prevent compatibility issues with build scripts.
- TFTP environment configuration to support SD boot and network boot scenarios for Kria boards.
- Support for non-root user creation, enabling better integration with host systems when using mounted volumes.
- Automatic sourcing of PetaLinux tools and TFTP service restart on container startup.
- Shared TFTP directory mounted and symlinked as
/tftpboot
inside the container.
This Dockerfile makes it easy to maintain a clean and isolated build setup, avoid polluting your host system, and ensure consistent builds across different machines.
Step 3: Launch the Container and Install PetaLinuxTo get started, simply launch the previously built container with appropriate volume mounts and privileges, as defined in the attached run.sh
script. Also, make the script executable:
chmod +x run.sh
./run.sh.
The container will:
- Start as the
kria
user - Map your local
workspace/
to the container’s working directory - Link your
/tools/
folder for access toPetaLinux tools
- Launch with full
/dev
access (for serial/UART tools, SD writers, etc.)
Inside the container, PetaLinux tools
will be automatically sourced, and the TFTP server will be restarted (via .bashrc entries).
You can safely ignore the “No such file” warning, because we haven’t installed the PetaLinux yet.
Run the PetaLinux Installer
Inside the running container, launch the installer:
/tools/petalinux-v2024.2-11062026-installer.run
- Accept the license agreement.
- When prompted for an installation path, enter:
/tools/petaLinux/2024.2
Important: Do not use the default path (like ~/petalinux). Stick to the one above to match your Docker setup.
Once the installation is complete, a few minor adjustments are needed before using the PetaLinux tools for the first time.
Fix “OS not supported” Warning - Optional
By default, PetaLinux does not officially recognize Ubuntu 22.04.5. To silence the warning:
vi /tools/petaLinux/2024.2/scripts/bash/petalinux-env-check
Edit line 48 and add your OS version (22.04.5) to the list of supported versions.
Prepare TFTP Boot Directory
Create a TFTP directory inside your ~/workspace
. This is useful for sharing boot files (like Image, system.dtb, boot.scr) with the board:
mkdir -p ~/workspace/tftpboot
This directory is automatically symlinked to /tftpboot
inside the container.
Source the Environment
Set up the environment by sourcing the settings script:
source /tools/petaLinux/2024.2/settings.sh
If all the previous adjustments were made correctly, the PetaLinux environment should initialize cleanly without any warnings
This script will be called automatically every time the container starts (already handled in the Dockerfile).
Exit the Container
Once setup is complete, you can exit the container:
exit
Now, your Docker-based PetaLinux environment is installed, patched, and ready to use.
Step 5: Verify PetaLinux EnvironmentRun the PetaLinux container again and once inside the container, run:
# run PetaLinux container
./run.sh
..
# inside container, show petaLinux help message
petalinux-create -h
If you see the help screen, everything is working and ready for use!
PetaLinux tools
are not installed inside theDocker
image. Instead, they are mounted from your host (/tools
), so updates don’t require rebuilding the image.- The container uses a non-root user (
kria
) that matches your host UID/GID for permission compatibility. - A symbolic link is created to your TFTP shared directory as
/tftpboot
.
In the next tutorial, you’ll learn how to:
Build a custom PetaLinux image from a hardware .xsa file entirely within this containerized environment.
Comments