DEV Community

Cover image for Docker Container: Docker Series 01
Ankur Singh
Ankur Singh

Posted on β€’ Edited on

3 1 1 1 1

Docker Container: Docker Series 01

Introduction

Welcome πŸ‘‹ to this blog. If you want to learn about Docker and are a complete beginner, you came to the right place. This blog series will cover everything from the very beginning to the end. This blog post will discuss what a container is, what Docker is, why Docker is necessary, and much more. So please stay with us until the end.

In software or application development we always have to face this problem:

"It works on my machine problem"

The main reasons for this problem are missing tools, different configurations, and hardware dependencies on different platforms.

Docker and container are the solutions to this problem.

Why we need Docker & Containers?

Suppose, my friend David and I are building a Flask web application I am using Ubuntu 22._ LTS and he is using Windows 11. I built the web app with some dependencies(e.g., Python version, Flask version, some run commands etc.) when I zipped the project folder and sent it to David, he called me and said It's not working on my machine then I replied It works on my machine problem. Can you guess why this happened?

[Think about it Comment below the answer]

The reason this happens is because of missing dependencies or conflicting dependencies. The simple meaning is that in the David system, there is a possibility that the dependency is not present(installed) or the version is not the same as my system's version. Then in this scenario, Docker and containers came into the picture.

Containers

Containers are like little boxes that hold an app and everything it needs to run, like tools and instructions. They help the app work the same way on any computer, without getting mixed up with other apps.

Don't confuse it with virtual machines, virtual machines are different things. Suppose in terms of the house, think of a virtual machine (VM) as a big house where each app gets its own full house with walls, a kitchen, and a bathroomβ€”it takes up a lot of space and needs a lot of work to build.

A container is like a small apartment in a big building. Each app gets its own room, but they share the walls and the building’s kitchen and bathroom, so it’s quicker and uses less space.

Containers VS VM(Virtual Machines)

Docker

Docker is a platform that allows developers to package applications and their dependencies into lightweight, portable containers. These containers run consistently across different environments, providing isolation and ensuring that the application functions the same on any system that supports Docker.

Installation

In Windows
You can download the exe file directly from the official website.

And install it manually.

In Linux

Step 1: Set up Docker apt repository

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Enter fullscreen mode Exit fullscreen mode

Step 2: Install the Docker package

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Enter fullscreen mode Exit fullscreen mode

Step 3: Verify that the installation

sudo docker run hello-world
Enter fullscreen mode Exit fullscreen mode

Conclusion

In this blog, we explored the basics of Docker and containers, highlighting their role in solving the "it works on my machine" problem by providing consistent application performance across environments. Containers are lightweight, efficient, and simpler to use than virtual machines, making them a valuable tool for developers.

Hire me: ankursingh91002@gmail.com
LinkedIn
Twitter

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

πŸ‘‹ Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay