Running ‘Hello, World!’ with BusyBox: A Docker Adventure
Last updated
Last updated
Once upon a time in the city of Athipati, there was a young coder named Arivanandham. Arivanandham had recently heard whispers of a magical tool called Docker, which promised to simplify the process of running applications. Eager to learn more, Arivanandham decided to embark on a quest—a quest to run the famous “Hello, World!” using the mysterious BusyBox Docker image.
Today, we’re going to take our first step by creating and running a container. And what better way to start than with a tiny yet powerful image called BusyBox? Let’s dive in and explore how to run our first container using BusyBox.
Our journey begins at the Docker Hub, the vast library of images ready to be transformed into containers. Let’s search for “BusyBox” on Docker Hub.
Upon searching, you’ll find the official BusyBox repository at the top. BusyBox is renowned for its compact size—about 1 megabyte—which makes it an excellent choice for quick downloads and speedy container spins.
Before we proceed, let’s check out the Tags tab on the BusyBox page. Tags represent different versions of the image. We’re going to pick tag 1.36 for our container. This specific tag will be our guide in this Docker adventure.
To start, we need to open a terminal. If you’re on Docker for Mac, Docker for Windows, or Linux, you can simply open your default terminal. If you’re using Docker Toolbox, open the Docker Quickstart Terminal.
When you instruct Docker to create a container, it first checks your local system to see if the image is already available. Let’s verify what images we currently have:
If this is your first time, you’ll see that there are no images available yet. But don’t worry; we’re about to change that.
Now, let’s run our first container! We’ll use the docker run
command, specifying the BusyBox image and tag 1.36. We’ll also tell Docker to execute a simple command: echo "Hello, World!"
.
Here’s what happens next:
Docker checks for the BusyBox 1.36 image locally.
If it’s not found, Docker will download the image from the remote repository.
Once the image is downloaded, Docker creates and runs the container.
And just like that, you should see the terminal output:
Hello, World!
Congratulations! You’ve just run your first Docker container.
Let’s run the docker images
command again:
You’ll now see the BusyBox 1.36 image listed. The image has a unique ID, confirming that it’s stored locally on your system.
Now that we have the BusyBox image locally, let’s run the same container again
This time, notice how quickly the command executes. Docker uses the local image, skipping the download step, and instantly spins up the container.
Let’s try something new. We’ll list all the contents in the root directory of the BusyBox container
You’ll see Docker output the list of all directories and files at the root level of the container.
To dive deeper, we can run the container in an interactive mode, which allows us to interact with the container as if it were a tiny, isolated Linux system. We’ll use the -i
(interactive) and -t
(pseudo-TTY) flags.
Now you’re inside the container! Try running commands like ls
to see the contents. You can even create a new file
You’ll see a.txt
listed in the output. To exit the container, simply type exit
.
It’s important to note that once you exit a container, it shuts down. If you run the container again using the same command, Docker spins up a brand-new instance. The file you created earlier (a.txt
) won’t be there because each container instance is ephemeral, meaning it doesn’t retain data from previous runs unless you explicitly save it.
And there you have it! You’ve successfully created, explored, and understood your first Docker container using the BusyBox image. This is just the beginning of what you can achieve with Docker. As you continue your journey, you’ll discover how containers can simplify development, testing, and deployment, all while keeping your environment clean and isolated.