Docker Essentials: A Beginner’s Blueprint 🐳

Upgrade your deployment skills with the Art of Containerization

Afaque Umer
Towards AI

--

Photo by Venti Views on Unsplash

Hey, there👋 Ready to embark on a Docker journey? 🚀 In this bite-sized blog, we’ll cut through the whys and hows of Docker concepts, no unnecessary theory here! We’ll wrap up by installing Docker on Linux via CLI. Why? So we can jump into deploying apps in the next blog without drowning in the theoretical sea. Buckle up for a quick ride into the Dockerverse — where containers rule, and boredom drools! 🐳✨

Before you dive into this, make sure to catch up on my earlier blog, where I guide you through setting up Linux using WSL 2, just in case you missed it. The installation of Docker assumes WSL 2 is already up and running. Here’s the link to the blog post 👇

A Developer’s Horror Story 💀

Imagine this scenario: You’ve wrapped up coding an exceptional application, and it runs flawlessly on your machine. However, when you attempt to run it on another environment, it’s like your code has ventured into an alternate universe where nothing seems to function! Welcome to the infamous realm of dependency hell.

Dependency hell is like having a recipe that only works in your grandma’s kitchen because it assumes she has that secret spice you can’t find anywhere else, and of course, who could forget the sacred meme 🙂

In Docker’s Sphere, Dependencies Disappear 🪄

In the Hogwarts School of Software, Docker is like a wizard who knows how to pack a suitcase efficiently. No more worrying about forgetting your favorite pair of socks (dependencies) or the right travel adapter (platform differences). With Docker, your application is always packed and ready for an adventure! It is the ultimate problem-solver in the developer’s toolkit.

Docker is a development tool and a virtualization technology used to simplify and automate the deployment of applications by putting it, along with its dependencies and settings, into a tidy container. A container, on the other hand, is a standard way to package an application that contains all the configuration files and other dependencies to operate the application. This eliminates problems like conflicting versions, inconsistent environments, and frustrating nights spent chasing mysterious bugs.

Docker sails the seas for a few compelling reasons🐋

Portability: Docker containers run consistently across various environments, from development to production.

Efficiency: Containers share the host OS kernel, minimizing overhead and maximizing resource utilization.

Isolation: Each container encapsulates its dependencies, ensuring application independence and preventing conflicts.

Scalability: Docker enables easy scaling by swiftly replicating containers, and responding dynamically to workload demands.

Version Control: Docker’s versioning system allows easy rollback to previous container states, promoting code stability and reproducibility.

Now that we’ve mastered Docker 101, let’s delve into essential terminologies and nomenclature. Familiarizing yourself with these will be a daily affair, and understanding the distinctions is key.

Virtual Machine vs Containers🤔

As we explore essential terms, it’s crucial to clarify a common source of confusion: the distinction between a virtual machine and a container. Let’s delve into this to ensure a clearer understanding.

Picture a computer as a city, and each application you run as a resident. A Virtual Machine (VM) is like having an entire apartment building for each resident it works, but it’s heavy and consumes a lot of resources. On the other hand, a Docker container is more like sharing an apartment building where everyone uses the same facilities efficiently. The key? Docker containers share the operating system’s kernel, making them super light and quick compared to the bulkier VMs. It’s like living in a city where everyone shares, making things faster and more efficient!

Understanding Docker’s Lingo 🦜

Now, let’s explore some terminologies that you’ll encounter regularly in the container lifecycle.

Container: An isolated unit that encapsulates an application along with its dependencies and runtime.

Image: A lightweight, standalone, and executable package that includes everything needed to run an application, including the code, runtime, libraries, and system tools.

Dockerfile: A script containing instructions for building a Docker image.

Registry: A centralized repository for storing and distributing Docker images.

Compose: A tool for defining and running multi-container Docker applications using a YAML file.

Volume: A persistent data storage mechanism in Docker that allows data to persist beyond the lifecycle of a container. etc.

Up until now, we’ve discussed fundamental and theoretical concepts. In this concise blog post, we prefer keeping theory and practical aspects separate. Now, let’s explore the installation of Docker on Linux WSL.

Before installing Docker, you need to ensure that your Linux distribution inside WSL has the necessary tools and libraries. The following commands configure Docker on WSL 2 by updating and upgrading the system, installing necessary dependencies, adding the Docker GPG key, incorporating the Docker repository, updating the package list, and finally, installing Docker Engine, Docker CLI, and containers. Additionally, the user is added to the docker group, granting them the ability to execute Docker commands without the need for sudo. This sequence of commands ensures a streamlined setup for working with Docker containers on the Windows Subsystem for the Linux 2 environment.

Docker’s architecture consists of two main components: the client and the server, where the server functions as the Docker engine. After completing the installations, a successful setup should display both the server and client information when executing the docker versioncommand. If only one component is shown or the information is incomplete, it indicates an unsuccessful installation.

Image By Author

Voila!!! There you have it Docker has been successfully installed on WSL2. That concludes this brief blog post, where we’ve covered the fundamental concepts and the Docker setup process. In our upcoming post, we’ll delve into creating a Python application and generating its corresponding Docker image.

I will try to bring up more Machine learning/Data science concepts and will try to break down fancy-sounding terms and concepts into simpler ones.

I hope you enjoyed this article! You can follow me Afaque Umer for more such articles.

Thanks for reading 🙏 Keep learning 🧠 Keep Sharing 🤝 Stay Awesome 🤘

--

--

AI whisperer, unraveling the secrets of the universe one byte at a time. Let's geek out together 👉 www.linkedin.com/in/afaque-umer