Building Efficient and Versatile Docker Images with Docker Buildx

I'm a tech enthusiast who loves to explore DevOps and Web development.
Search for a command to run...

I'm a tech enthusiast who loves to explore DevOps and Web development.
No comments yet. Be the first to comment.
A few months ago, my product manager dropped something in the team channel. "We are adding an AI agent to the platform next quarter. It will handle follow-ups automatically." Just like that. One messa

f you’re diving into React, you’ve likely come across the useRef hook. But what exactly is useRef(), and how can it make your life easier? In this post we’ll cover what useRef is, walk through five

A bug that only happens for some users, that you can never reproduce, that isn't in your code. Welcome to the React + browser-translation crash — what causes it, why it's so sneaky, and the battle-tested one-file fix.

Upgrading a core production database is usually the stuff of dev nightmares. It often involves maintenance windows, scheduled downtime, and the looming fear of a botched migration. But what if you cou

We are moving into products that adapt, predict and react with real context. Designing only interfaces is not enough anymore. We are designing experiences that understand the user. Designers and digital agencies are now challenged to move beyond trad...

Engineering at JoBins
167 posts
Welcome to Engineering at JoBins — where we share the stories, insights, and lessons from building a world-class hiring platform. From system design and scalability to developer tools and team culture, our engineers write about the real challenges we solve every day. Whether you're a curious developer or a fellow builder, we hope our experiences inspire and inform your own engineering journey.
Docker is an essential tool for modern developers, allowing for the creation, deployment, and management of containerized applications. One of the powerful features of Docker is Docker Buildx, an experimental CLI plugin that extends the functionality of docker build. This blog will guide you through an interactive journey of leveraging Docker Buildx to create and manage builders, focusing on the commands:
docker buildx create --name local_remote_builder --node local_remote_builder --node intelarch --platform linux/amd64,linux/38 --driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=10000000 --driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=10000000
docker buildx create --name local_remote_builder --node aarch6 --append --platform linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/mips64le,linux/mips64,linux/arm/v8,linux/arm/v7,linux/arm/v6 ssh://user@xxx.xxx.xxx.xxx --driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=10000000 --driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=10000000
docker buildx use local_remote_builder
Creating a builder with multiple nodes allows you to build images for various platforms simultaneously. Here, we create a builder named local_remote_builder with nodes for different architectures.
docker buildx create --name local_remote_builder --node local_remote_builder --node intelarch --platform linux/amd64,linux/38 --driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=10000000 --driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=10000000
--name local_remote_builder: Names the builder instance.
--node local_remote_builder: Adds a node to the builder.
--node intelarch: Adds another node, targeting Intel architectures.
--platform linux/amd64,linux/38: Specifies the platforms for the build.
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=10000000: Sets the maximum log size for the build steps.
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=10000000: Sets the maximum log speed.
To support even more platforms, you can append additional nodes to your existing builder. Building ARM architecture images on an AMD CPU can be very time-consuming, so it's more efficient to use an ARM instance and access Docker remotely via SSH.
docker buildx create --name local_remote_builder --node aarch6 --append --platform linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/mips64le,linux/mips64,linux/arm/v8,linux/arm/v7,linux/arm/v6 ssh://user@xxx.xxx.xxx.xxx --driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=10000000 --driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=10000000
--append: Appends new platforms to the existing builder.
ssh://user@xxx.xxx.xxx.xxx: Specifies the remote SSH endpoint for the build node.
After setting up your builder, you need to specify it as the active builder.
docker buildx use local_remote_builder
This command activates the local_remote_builder for subsequent build operations.
Docker Buildx is a powerful tool that enhances the standard docker build command, enabling efficient multi-platform builds. By following the steps outlined above, you can create versatile builders that cater to various architectures and platforms, ensuring your applications are robust and widely deployable. Utilizing ARM instances for ARM builds ensures efficiency and saves time, allowing for a smoother development process.
To further understand these commands, you can run them in a Docker-enabled environment and observe how each step contributes to the build process. Feel free to tweak the parameters and explore different configurations to see how they affect your builds.
Happy building!