Docker is revolved around 2 major issues:
1- The Application that runs on my machine is not quite guaranteed to run on another machine.
2- Setting up a new environment is a time-consuming process.
There are numerous benefits of using docker but we will discuss that later.
To understand Docker effectively, it's important to first explore the fundamentals of virtualization and containerization. However, before diving into those concepts, let’s get started by setting up Docker on your system.
Virtualization and Containerization in next chapter
Setting up docker in Linux machine
Installing with apt
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
Install the latest version
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Verify installation:
docker --version
Official installation documentation here: https://docs.docker.com/engine/install/ubuntu/
Here, I have shown how to do it on Ubuntu Server. Depending upon your Os type you can follow the official documentation guide.
Setting up docker in Macos machine
- Visit this url https://docs.docker.com/desktop/setup/install/mac-install/
- Choose the correct version for your processor (Apple Silicon or Intel). If you have m1 chip download from the button that says
Docker Desktop for Mac with Apple Silicon
if not use another button to download. - Open the downloaded .dmg file and install
- Open Docker from the Applications folder or Spotlight search.
- Grant necessary permissions if prompted.
- Sign in with your Docker Hub account or create one if you don’t have it.
Setting up docker in Windows machine
1. Download Docker Desktop:
- Visit the Docker Desktop for Windows page. https://docs.docker.com/desktop/setup/install/windows-install/
- Download the installer, depending upon your Windows type. AMD or Arm
2. Install Docker Desktop:
- Run the installer and follow the setup wizard.
- When prompted, ensure Use WSL 2 instead of Hyper-V is selected (if you're on Windows Home).
- Restart if necessary.
3. Launch Docker Desktop:
- Open Docker Desktop from the Start Menu.
- Sign in with your Docker Hub account or create one.
Back to the problem, how docker solves the issues of incompatibility:
To make it easy to understandable let's put it like this. I drew one sketch and asked another guy to draw the same, he might be able to but will of course be hard for him to have an exact copy of mine.
The solution could be,I will provide him sketch as a base image to follow and just ask to do photocopy of it instead of drawing it again which will solve the two problems:
- Now the duplicate sketch will be exact the same
- Secondly, it will save a lot of time for him.
We have a similar concept in docker we create a base image first keeping all the application codes and dependencies which will then be used to create a docker container.
Dockers Basic two concepts to understand:
Docker image:
We need the docker image to run an application as docker container.
It's a process of attaching all the codes and dependencies required by the application.
We can either create our own docker images or use those pre-built by someone and publicly available. We will learn later how to create a docker images.
Docker container:
We run a docker image which when runs is termed as docker container.
Final though: we compact everything into docker image which can be transferred to any machine and is guaranteed to have the same codes and dependencies and run without any configuration hassle.
Top comments (0)