An exercise in Discovery, Building Docker Images, using Makefiles & Docker Compose. — Part 2

George Leonard
3 min readAug 22, 2024

--

Let’s build Apache Hadoop DFS cluster.

(See: Part 1)

(22 August 2024)

Overview

Ok we will start with our base OS image. This will form the foundation for the entire build.

See the build-ubuntu-os-20.04 sub directory of the project Repo.

NOTE: this is one of our ARM64 specific images, to revert to standard AMD64 (Intel), simply remove the arm64v8/ bit from the FROM clause to pull the Intel/AMD64 based image.

First Dockerfile

FROM arm64v8/ubuntu:20.04

# original https://github.com/YanYunNN/hadoop-cluster-docker-m1/blob/main/Dockerfile

WORKDIR /root

RUN echo "--> Install OS dependencies openssh-server & misc tools" && \
build_deps="openssh-server wget neovim curl unzip net-tools" && \
apt-get update && \
apt-get install -y $build_deps

RUN echo "--> Purge apt artifacts" && \
apt-get purge -y --auto-remove $build_deps && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

We start our build by specifying our source image, in this case arm64v8/ubuntu:20.04.

Source images are sourced from ether Docker hub or Google Container Registry primarily.

Next, we define WORKDIR /root this accomplishes 2 things for us; it creates the directory if it does not exist, and it changes into the directory, making it our current working directory in which all commands are executed.

Following this we execute a docker primitive/command called RUN. I always start the command with echo “some text” to output a description of what’s being done, followed by “&& \” which creates a line continue onto the next line.

RUN echo "--> Install OS dependencies openssh-server & misc tools" && \
build_deps="openssh-server wget neovim curl unzip net-tools" && \
apt-get update && \
apt-get install -y $build_deps

With the second line we define a local variable “build_deps” to which we assign a list of packages that we want to install using the apt-get install command which is executed after our apt-get update to update the local package library.

Re: build_deps=”openssh-server wget neovim curl unzip net-tools”

The value of using a variable here is seen in the next RUN command where we clean up after the install and now instruct apt-get to clean up, using: apt-get purge — auto-remove &build_deps reusing variable/list define previously.

RUN echo "--> Purge apt artifacts" && \
apt-get purge -y --auto-remove $build_deps && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

NOTE: Lesson learned, the standard package vim during installation request’s physical location via a prompt which can’t be by passed (or i have not figured out how), but neovim on the other hand does not, and it does the same.

The build is executed by calling make build in the same directory (See the Makefile), this in return issue:

sudo docker build -t ubuntu20.04:$(VERSION) .

To see the output image execute docker images.

Ok, that’s all for Part 2. In the next part we will move onto building our base Open JDK 11 application server using our newly built base image.

See Building Docker Images for all the code.

About Me

I’m a techie, a technologist, always curious, love data, have for as long as I can remember always worked with data in one form or the other, Database admin, Database product lead, data platforms architect, infrastructure architect hosting databases, backing it up, optimizing performance, accessing it. Data data data… it makes the world go round.

In recent years, pivoted into a more generic Technology Architect role, capable of full stack architecture.

George Leonard

georgelza@gmail.com

--

--

George Leonard

I'm a techie, a technologist, technology architect, full stack architect, Always curious, Love data and data platforms.