Before we start learning Docker commands, let's look at a very practical example that will give us complete clarity on what Docker exactly is.
We have a host machine — let's say a Mac OS system. On this Mac OS, suppose we want to run an Ubuntu system. The command to do this (which we will cover in detail later) looks like:
docker run -it ubuntuThis command runs an Ubuntu container inside Docker in interactive mode, allowing us to access the terminal of that container.
As soon as this command is executed, Docker:
We can verify this using Docker Desktop. In the Containers tab, we can see:
Inside the container, we are placed in the root directory. The files and folders visible there belong only to the Ubuntu container.
For example:
Even if we delete the entire container tomorrow, our Mac OS remains completely unaffected.
In this example, we:
This is the core idea of Docker.
Docker is similar to a Virtual Machine (VM), but it is much more lightweight, faster, and easier to work with.
To set up Docker, visit docker.com and download Docker Desktop.
Docker Desktop is available for both Mac and Windows systems.
Open the terminal (Mac/Linux) or Command Prompt (Windows) and run:
dockerIf Docker commands are displayed, Docker has been installed successfully.
To check the Docker version:
docker -vExample output:
Docker version 28.x.x, build xxxxxxxJust as GitHub is a central repository for source code, Docker Hub is a central repository for Docker images.
Docker Hub contains thousands of public Docker images that can be downloaded and used directly.
When Docker cannot find an image locally, it automatically pulls it from Docker Hub.
Visit:
https://hub.docker.comDocker Hub acts as the central registry from which Docker retrieves images whenever they are not available on the local machine.