CC Blog • Design Solutions • Research & Design Hub

Containerize Your Build System using AI

Written by Jacob Beningo

Docker can streamline your embedded development process, containerizing your build environment, ensuring consistency and eliminating toolchain discrepancies across team members. You can leverage AI to optimize your Dockerfile, and enhance efficiency in setting up and managing complex development environments.


  • What is Docker and why is it useful for embedded development?
  • How does containerizing a build system improve team consistency?
  • What is included in a Dockerfile for an embedded environment?
  • How can AI help create and optimize a Dockerfile?
  • How do you build, run, and share a Docker container?
  • Docker
  • AI-assisted development
  • containerization
  • CI/CD
  • Docker | docker.com
  • Embedded Software Academy | beningo.com
  • Arm | arm.com
  • General Motors | gm.com
  • NASA | nasa.gov
  • University of Michigan | umich.edu

Have you ever spent considerable time at the start of a project installing numerous tools such as compilers, debuggers, Python, static analyzers, code formatters, and more? Setting up these tools is always a pain, but in a team setting, getting the same tools set up and ensuring everyone continues to use them is even more so.

I recall a specific project where an application compiled and ran perfectly fine for one developer, but another developer found that the application would crash. Same code. Different outcomes. What was the root cause? The two team members had different versions of the compiler, and one had a bug!

So, how do we ensure we avoid time-consuming build system setups, have the same tools, and help new teammates get up to speed quickly? We can containerize our build environment using tools like Docker!

In this article, we’ll walk through:

  • What Docker is and why it matters
  • How to leverage AI to create an embedded development container
  • How to build and run your container
  • Practical examples to demonstrate the use of containers in embedded development
  • Let’s dive in.
What is Docker?

At its core, Docker is a platform that enables you to package your entire build environment including compilers, debuggers, Python tools, static analyzers, and any other necessary components into a single container. Think of it like a portable box that contains everything your software project needs to build and run.

There are several benefits that Docker brings to your development environment:

  • A consistent build environment (the same for everyone)
  • Isolation (your build environment is separate from your host environment)
  • Dependency control (you control the dependencies and versions of software)
  • Portability (create one container and distribute to a whole team or customer)
  • CI/CD Integration (easily integrate builds into CI/CD platforms)

Figure 1 illustrates an example of the Docker architecture. There are five key pieces of this diagram that we want to pay attention to.

  • The Client provides a command-line interface to interact with the Docker Daemon.
  • The Docker Daemon runs on a host machine and listens for API requests and manages Docker objects.
  • Images are ready-to-use templates with instructions for creating a container.
  • Containers are the runnable instances of an image.
  • Registries contain images, extensions, and plug-ins.
Figure 1
Docker Architecture Overview (Source: https://docs.docker.com/get-started/docker-overview/)
Figure 1
Docker Architecture Overview (Source: https://docs.docker.com/get-started/docker-overview/)

When I first heard about Docker, I’ll admit, I thought it was overkill, yet another trendy cloud tool with no place in firmware. But after one too many build issues caused by tool version mismatches, I gave it a try. And I’ve never looked back. Today, my first step on any new coding project is to create a build container.

The key to containerizing your build environment is to write a Dockerfile that includes all the necessary components for your build system. Let’s look at what is included in a Dockerfile.

The Anatomy of a Dockerfile

A Dockerfile is a simple text file that contains step-by-step instructions for building your Docker image. Think of it as a recipe for setting up your build environment.

Figure 2 shows a minimal example for an embedded build environment using armnoneeabigcc and CMake.

Figure 2 
Example Dockerfile for an Embedded Build System
Figure 2
Example Dockerfile for an Embedded Build System

This base container gives you a reproducible, host-independent environment for building and debugging embedded projects. Every team member receives the same tools, the identical versions, and the same behavior, regardless of whether they’re using macOS, Windows, or Linux. (Although in this case, we are pulling whatever the latest version is, but I’ll show you some ways to force the version later.)

You can even extend this with additional tools, such as static analyzers (cppcheck, for example), code formatters (clang-format, for example), or Python packages that are part of your continuous integration (CI) pipeline.

Before we use AI to create a custom container, let’s examine how we build this image and how AI tools can help make the process faster and easier.

Building the Docker Container

The first step to building a container is to have Docker installed. You can do this by going to the Docker website and downloading Docker Desktop. Docker Desktop includes all the tools you need to run Docker locally.

Once you have it installed, make sure that it is running in the background.

Next, you can run the Docker build command from your terminal manually, or you can create a makefile. I personally prefer to create a makefile because I don’t want to memorize commands. I can create the command once and then just run my makefile.

There are two commands that we’ll want in our makefile:

docker_build

docker_run

As you can guess from their name, they build our image and run the container. Figure 3 shows an example of what the makefile looks like.

Figure 3 
A makefile that includes commands to build and run a Docker container
Figure 3
A makefile that includes commands to build and run a Docker container

Running the commands is straightforward. First, build your container with the following command:

make docker_build

Docker will process the Dockerfile commands, download, and install the packages and applications that are specified. When completed, it will look something like Figure 4.

Figure 4 
A successful Docker image build
Figure 4
A successful Docker image build

Having a successful image build is a good step. Next, we want to run the container. We can do this through our makefile by running the command:

make docker_run

When we do this, we should find ourselves inside a command prompt that looks like the following:

root@3dfccb563701:/workspace#

You can test that the tools you want installed are there by typing commands like:

cmake –version

ninja –version

python3 –version

The container that we just built is a good first container, but it doesn’t have all the bells and whistles we really want. For embedded software development, we need to make some changes. These changes can be done manually, like I’ve done hundreds of times before, or we can have some fun and use the “magic” of AI.

Leveraging AI to Improve Your Container

There are several different AI tools you can use to improve the Dockerfile. Some of these tools include:

  • ChatGPT
  • Claude
  • Cursor
  • Windsurf
  • Ollama

I’m going to use Windsurf because it allows me to open a project just like Visual Studio Code (which it is based on) and because it can then directly manipulate my Dockerfile. I can even have it run commands for me if I want.

Before we just start changing the file, we need to identify what we want to do. I have a laundry list of things I’d like to see in our containerized build system.

First, I want to specify the exact version of the Arm compiler that is used. This was released recently, in December 2024, as Version 14.2.Rel1.

Next, I want to make sure that we use supporting tools to analyze any application code. This would include tools like:

  • clang-tidy
  • clang-format
  • cpputest
  • pmccabe

We should also make sure that we include West.

Finally, I think it’s important that we also build a test harness into the container. For this example, we’ll use cpputest and gcov.

From this list, let’s build a prompt to ask AI to make these changes for us. The prompt I can up with can be seen in Figure 5.

Dockerfile Environment Setup
Dockerfile Environment Setup

Now, when I ran this prompt, the AI chewed on it for a bit then came up with a solution. I won’t share the exact version yet because it didn’t work! When I tried to run docker_build, I encountered permission errors.

Reading the Dockerfile, I could see that the order of tool installion was not correct. Instead of fixing it manually, I decided to let the AI take a crack at it with this prompt:

— ADVERTISMENT—

—Advertise Here—

Can you run the docker_build command and fix any errors present?

The AI took up the challenge. It didn’t get it in one try. In fact, it made the changes it thought it needed, reran docker_build, collected the error and repeated the process several times.

The reason I like using AI tools like Windsurf or Cursor is that you aren’t just performing one-off prompts, you have an AI Agent that is analyzing and taking action! So, instead of seeing an issue, copying and pasting, and asking for a fix, you can have the AI go through and iterate on its own until it solves the problem. Pretty cool! (While the AI was churning out options, I managed to respond to a few emails).

Let’s take a look at what the AI generated for our Dockerfile improvements. First, take a look at Figure 6 to see how the environment is set up. You can see that we are using ubuntu 22.04 in a noninteractive mode. That means the user, us, is not responding to any prompts for tool installation. We then have some paths and workspace directories defined.

Figure 6 
Dockerfile Environment Setup
Figure 6
Dockerfile Environment Setup

Next, take a look at Figure 7 which shows the new applications that are being installed. You can see that all the tools we requested to be added have been! In fact, there are additional tools there that we didn’t request. Those have been added to support the tools we did request, along with tools the AI thought we may want for embedded development.

Figure 7 
Tool Installation
Figure 7
Tool Installation

Note: There were some additional libraries being installed that I removed. Sometimes AI adds extra stuff we don’t need. That’s why it’s critical not to trust it and review the code that it generates.

You might have noticed that there is no Arm compiler installed. This is done in the last step of the Dockerfile as you can see in Figure 8.

Figure 8 
Dockerfile Arm tool installation
Figure 8
Dockerfile Arm tool installation

With these enhancements, you can build and run your container. When you run it, the prompt for the container has now changed to the following:

dev@e7ab7b2085bc:/home/app$

You may be wondering why we’re now dev instead of root. Well, I added the following lines of code to my Dockerfile after the tool installation but before installing the Arm compiler:

# Create user and directories

RUN useradd -ms /bin/bash dev && \

mkdir -p /home/dev /home/app && \

chown -R dev:dev /home/dev /home/app

Instead of developing in root mode, we are in a user mode that limits the permissions within the container.

Accessing Your Application Within the Container

There’s one last trick that I have in store for you today: accessing your host file system, allowing you to share your application code between your host environment and the container.

The reason you might want to do this is that debugging from within a container can be problematic if you are using MacOS. The container is running on top of a virtual machine, which doesn’t give easy access to the USB ports like on Windows or Linux.

The simplest solution is to share your code and build assets between your local host and the container. That way you can build in the container but run a debug session on your host machine.

To mount your local file system, the folder you launch the docker_run command from, you just need to update your makefile.

We’ll update docker_run from:

docker run -it –privileged –rm $(DOCKER_IMAGE_NAME) bash

— ADVERTISMENT—

—Advertise Here—

to:

docker run -it –privileged –rm -v $(CURDIR):/home/app $(DOCKER_IMAGE_NAME) bash

We use the parameter -v to mount the volume. Now, if you perform an ls command within the container, you’ll see the contents of the folder we launched the container from. (For now, this would show your Dockerfile and makefile, but eventually your whole application).

Start with a container

Containers are a powerful tool for packaging your build system. Containers help isolate your toolchain and settings from your host, ensuring there are no conflicts. It also enables CI/CD, allowing you to share your build system with colleagues and eliminate potentially problematic toolchain issues.

At this point, you’ve got the tools to:

  • Write your own Dockerfile
  • Use AI to improve your container template
  • Build your container
  • Run it with your own custom settings
  • Reuse your build system across platforms and products

Here’s where you can go from here:

  • Install Docker Desktop
  • Open a test project folder in Cursor, Windsurf, or your favorite AI toolchain
  • List the tools you need for development
  • Leverage AI to write your Dockerfile
  • Build and test your container

Containers don’t just enable you to package up your build system, they enable you to adopt modern practices like CI/CD that scale your software development.

So the next time you start a new project, don’t begin with an integrated development environment install or a toolchain download. Start with a container. Your future self—and your team—will thank you. 

RESOURCES
Docker | www.docker.com

REFERENCES
[1] Modern Embedded CMake Build System Download
https://www.beningo.com/embedded-software-cmake-build-system/
[2] west documentation: https://docs.zephyrproject.org/latest/develop/west/index.html
[3] Docker documentation: https://docs.docker.com/

PUBLISHED IN CIRCUIT CELLAR MAGAZINE • AUGUST 2025 #421 – Get a PDF of the issue

Keep up-to-date with our FREE Weekly Newsletter!

Don't miss out on upcoming issues of Circuit Cellar.


Note: We’ve made the Dec 2022 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine.

Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.

Sponsor this Article

Supporting Companies

Upcoming Events


Copyright © KCK Media Corp.
All Rights Reserved

Copyright © 2026 KCK Media Corp.

Containerize Your Build System using AI

by Jacob Beningo time to read: 9 min