Docker Buildx

Vidushi BansalVidushi Bansal
2 min read

As part of containerization, you've likely built numerous Docker images to run your applications. But how often have you encountered the issue of an image not being compatible with your system's processor architecture? For instance, imagine you’re using Ubuntu on a machine with an AMD-based processor(x86). When you install Docker and build images, by default, those images will be tailored to the architecture of the underlying system—in this case, AMD.

What if you need to run those images on a server that doesn’t support the same architecture?

In such cases, you’ll encounter an error, and the container simply won’t start. This incompatibility between the image’s architecture and the server’s processor can be a significant roadblock, especially when deploying across diverse environments.

We will address this issue and learn how we can create images for different processors.

Prerequisites:

Install docker

Follow https://docs.docker.com/engine/install/ to install docker in your system.

Building Docker Image

Creating a simple Dockerfile.

FROM nginx

COPY index.html /usr/share/nginx/html

This will copy my custom index.html file to the container and the content will be displayed on port 80.

Creating docker image the generic way:

docker build -t webserver:amd .

Listing docker image

docker images

We have added amd tag to identify the processor, but to check if its based on amd, we can inspect the image.

docker inspect webserver:amd | jq '.[] | .Architecture'

It will, by default, use amd64 as underlying architecture.

Now lets create arm based:

docker buildx build --platform linux/arm64 -t webserver:arm .

Lets inspect the image to check the architecture.

This is how you can create images compatible with any architecture.

1
Subscribe to my newsletter

Read articles from Vidushi Bansal directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Vidushi Bansal
Vidushi Bansal

DevOps enthusiast on a constant quest for knowledge! From wrangling complex pipelines to exploring the latest tech stacks, I’m all about learning, leveling up, and debugging with a smile. Whether it’s automating, collaborating, or diving into the world of cloud, I’m always ready to build and improve. Let’s innovate together!