What is Docker Desktop & How Does it Work?
It is often imperative to first understand the history behind any tools and tech to understand from where it came and why it was created even in the first place. So to get into history, Docker first saw its light in 2011 in France when Solomon Hykes envisioned building platform-independent mechanisms to deploy all your development binaries in such a way that all the libraries, os level dependencies, and codes can be deployed on any cloud or system giving the developer confidence that their software will function as expected without any rework and hiccups.
The core reason for docker container conceptualization was to make a developer’s life easy. Setting up a working environment configuration to support different software versions on any given machine was a big issue. But with docker, you just need to create an isolated package comprising of all the configurations (called docker container) supporting different versions, and each container here holds a separate isolated environment configuration that doesn’t impact the OS level configs or any other running container active on your machine.
Now that we have some basic idea of why docker was started and created, it’s a high time we define a few components to establish docker as a concept. So the first thing is to define Docker. Know more about devops skills that a devops engineer should master.
What is Docker?
Docker is like that huge Cargo Ship loaded with big boxes (unique containers to be pulled by the tagged owners) that offers developers a Software platform that allows them to build, test, and deploy applications quickly. Docker packages software into standardized units called containers that have everything the software needs to run including libraries, system tools, code, and runtime.
Docker provides the ability to package and run an application in a loosely isolated environment called a container. The isolation and security allow you to run many containers simultaneously on a given host.
To further understand the magic of docker we need to decode the Docker architecture as it lays down clearly how each component of the Docker system interacts with the others.
Docker Architecture
Fig 1- Docker Architecture Docker has three major components:
- Client
- Docker Host
- Registry
Let’s dig deeper into each one of these, one by one. First and foremost we need to understand the docker daemon.
If you want to know more about docker and get a practical sense of it, you can explore our dedicated docker online course.
What Is Docker Deamon?
It is a kind of persistent thread that runs in the background in order to manage the Docker containers on a single host.
Docker daemon also known as dockerd, runs on the host operating system acting like a runtime that takes care of docker objects like
- Docker images
- Docker containers
- Networks and
- Storage
Now that you know the basics of docker daemons let's understand the first key component of Docker architecture
Docker Client
As it is seen, in Fig 1, the docker client is like your local machine where all the necessary client operations are performed by the users. This client gives developers a primary interface (CLI) to interact with the Docker server (daemons) using the pre-defined set of commands
Its main objective is to provide a medium to direct the pull of images from a registry and to have it run on a Docker host. Common commands issued by a docker client are:
$ docker build
$ docker pull
$ docker run
Docker client uses these commands and REST APIs to interact with Docker daemon which also is a Server. Do you know that the Docker client can communicate with more than one daemon?
Docker Host
It is a complete hosting environment that holds docker daemon, containers, images, networks, and storage that is required by developers to execute and run any given applications
Docker Registry
The primary role of the docker registry is to store docker images. These image repositories can be either public or private. The popular public registry is the Docker hub.
So whenever you as a developer are looking to pull one of the docker images using the docker pull command, the required images are pulled from your publicly configured registry (like docker hub). Similarly, when you use the docker push command, your image is pushed to your configured registry.
Before we wrap up the docker fundamentals we also need to touch upon the docker objects.
Docker Objects
You can’t fully understand Docker without understanding the underlying docker objects. Some of the key objects are
- Docker Images
- Docker Containers
Docker Images
Being a developer you would have for sure came across a situation where the development you have done locally on your PC/Laptop requires you to configure your editor, OS dependencies, libraries, environment variables, etc to package and run your code binary. But if your system breaks down due to some reason and you are asked to move to a new PC/Laptop, that old code binary struggles to run as expected on it.
But in the current time, this is not the case thanks to Docker and a docker objects called Image.
Docker image
It is nothing but a read-only template that has all the instructions required to create a docker container(another object which we will cover next). These images use as a private container registry to share container images either publicly or privately. Every packed image in the container is meta-tagged to explain the container’s ability.
These images are at the core of the Docker ecosystem, as they foster team collaboration and speedy development and deployment. The kind of experience it brings is simply commendable and that’s why Docker images and their underlying utility are so popular in the developer and tech fraternity.
Dockerfile
Being a developer, you may simply use docker images created by someone and shared publicly or maybe want to create a custom image to be used within the organization. While creating a custom image you rely on the concept of Dockerfile which defines a simple syntax comprising the steps needed to create the image and deploy it on Docker hub/ AWS ECR repo.
Dockerfile has all the instructions which are created as a separate layer in the docker image, so whenever you update the docker images only those layers which have changed are rebuilt. This is the reason which makes docker images so lightweight, tiny, and quick as compared to the older concept of virtualization
Docker Containers
Now that we know the basics of docker images it's time to decode another key docker object called Containers.
Containers are nothing but the runnable instance of a docker image.
Runnable is an interface that is to be implemented by a class whose instances are intended to be executed by a thread.
These containers can be
- Created
- Started
- Stopped
- Moved
- Deleted
All by the use of Docker CLI/API.
Containers are isolated pieces that can be plugged into one or more networks and also allow storage to be associated with it. Each container that are hosted in Docker Host is unique and is defined by the images it holds as well as by the configs.
Do you know?
When a container is deleted, all the changes to its state that are not stored in persistent storage vanishes.
With this, we have covered all the fundamentals one should before knowing Docker Desktop. So let’s start defining. But before that, get to know more about how to become a devops engineer.
What Is Docker Desktop?
As we have understood so far that docker objects like images and containers are key building blocks, it is also imperative to know that these objects are generally dockerized, and here the role of Docker Desktop comes into the picture.
Docker desktop is the fastest way to containerize/dockerize applications. It is a native application designed by Docker for both Windows and MAC users.
Why Docker Desktop?
Docker desktop that is built on top of the Docker engine is a perfect tool for developers that are looking to leverage the Docker ecosystem and get started quickly to dockerize and deploy their apps. It is a powerful tool that packages Docker’s CLI, Docker Compose, Kubernetes, and other tools to Fastrack application development.
It is easy to install and OS independent and comes up with these key features that make it stand out amongst others
Top Features that Makes Docker Desktop Special
- Simple and easy-to-install providing an environment to build, ship, and run your containers
- Storage volumes are easily mapped and managed
- Supports both Local and remote management of Docker images
- Facilitates collaborations amongst developers where they can share repeatable and reproducible development from their local machine to the docker container
- Easy to get started with Kubernetes on your local machine with Docker Desktop.
- Provides a simple dashboard to help developers get an overview of running containers, images, and volumes
- Tailor-made to support multi-architecture images
Now that we have got enough reason to use the Docker desktop it's time to get decode how one can install it and get started.
Getting Started With Docker Desktop for Windows & Mac
Before we kickstart this phase its important to understand a few things
What are a few things to know?
- Docker desktop supports both Windows and MAC systems.
- One should use a community open source edition to get started with Docker desktop
- Also, there is a commercial edition that is suitable for enterprises and a large team
- Commercial use of Docker Desktop in larger enterprises (more than 250 employees OR more than $10 million USD in annual revenue) now requires a paid subscription.
Installing Docker Desktop On Mac
Docker desktop comes with two versions for mac
- One for MAC with Intel Chip
- One For MAC with its own indigenous Apple chip
Pre-requisites Of MAC — Intel Chips :
- macOS must be version 10.15 or newer. That is, Catalina, Big Sur, or Monterey.
- Run the command kern.hv_support to verify if MAC hardware supports the Hypervisor framework
- If you experience any issues after upgrading your macOS to version 10.15, you must install the latest version of Docker Desktop to be compatible with this version of macOS.
- At least 4 GB of RAM.
- VirtualBox prior to version 4.3.30 must not be installed as it is not compatible with Docker Desktop
Installing Docker Desktop On MAC — Intel Chip:
The best way is to visit
Install Docker Desktop on Mac
Estimated reading time: 7 minutes Update to the Docker Desktop terms Commercial use of Docker Desktop in larger…docs.docker.com
And download the latest Docker installation file from there, you will get the options as depicted below.
Click for the intel version and wait till the docker .dmg file is downloaded. Once done just click the file and the rest will be an easy cakewalk as the wizard will be there to guide you. You must read and agree on the SLA which will be popping on your MAC to proceed.
Similarly, you can install docker desktop on your MAC with an Apple silicon chip
Pre-requisites Of MAC — Intel Chips :
- It is recommended that you download the latest Docker Desktop version. With version 4.3.0, the hard requirement to install Rosetta 2 is no more required but still, to get the best-uninterrupted experience, it is wise that you install Rosetta 2.
- One can install Rosetta 2 manually from the CLI, using the following command:
$softwareupdate --install-rosetta
Installing Docker Desktop On MAC — Apple Silicon Chip:
The process through guided wizard remains the same. Download the .dmg file for the Apple silicon version and the rest you can easily set up using Wizard after you have given your consent against the SLA.
Installing on MAC using CLI: (for both chip types it works )
Once you have downloaded the preferred .dmg file considering your MAC machine chip type (Intel/Apple silicon) you can easily install the docker desktop via CLI commands as shown below.
You need to type these commands on your mac terminal
$ sudo hdiutil attach Docker.dmg
$ sudo /Volumes/Docker/Docker.app/Contents/MacOS/install
$ sudo hdiutil detach /Volumes/Docker
What is hdiutil?
hdiutil is a command-line utility in macOS to Manipulate disk images (attach, verify, burn, etc).
$ sudo /Volumes/Docker/Docker.app/Contents/MacOS/install
Here install command accepts the following arguments -
- --accept-license: accepts the Docker Subscription Service Agreement(SLA) now, rather than requiring it to be accepted when the application is first run
- --allowed-org=<org name>: requires the user to sign in and be part of the specified Docker Hub organization when running the application
If you are done installing, you may be able to open it by visiting your launchpad and clicking on the docker icon
Once you click, you can see the docker fav menu icon on the extreme top right of your MAC as seen in the image below, in my case you can see a first small icon that starts to animate and you will see the docker desktop dashboard as shown below.
It will show you the current docker images, volumes attached, and the environment info. This means you are now successfully running Docker Desktop. You can click the docker fav menu icon to see Preferences and other options.
Installing Docker Desktop On Windows
Visit this official docker link -
Install Docker Desktop on Windows
Update to the Docker Desktop terms Commercial use of Docker Desktop in larger enterprises (more than 250 employees OR…docs.docker.com
And select the option as shown below-
Pre-requisite:
You should take care of the following before installing docker desktop on your windows machine:
- Windows 11 64-bit: Home or Pro version 21H2 or higher, or Enterprise or Education version 21H2 or higher.
- Windows 10 64-bit: Home or Pro 21H1 (build 19043) or higher, or Enterprise or Education 20H2 (build 19042) or higher.
- Enable the WSL 2 feature on Windows. For detailed instructions, refer to the Microsoft documentation.
Windows Subsystem for Linux is a compatibility layer for running Linux binary executables natively on Windows 10, Windows 11, and Windows Server 2019. In May 2019, WSL 2 was announced, introducing important changes such as a real Linux kernel, through a subset of Hyper-V features
- The following hardware prerequisites are required to successfully run WSL 2 on Windows 10 or Windows 11:
- 64-bit processor with Second Level Address Translation (SLAT)
- 4GB system RAM
- Hyper-V and Containers Windows features must be enabled.(only if you want Hyper-V option instead of WSL 2)
- BIOS-level hardware virtualization support must be enabled in the BIOS settings. For more information, see Virtualization.
- Download and install the Linux kernel update package.
Installing Docker Desktop On Windows Using Wizard:
- Double-click Docker Desktop Installer.exe that you downloaded as per the instructions we have covered above in order to run the installer.
- When asked, ensure WSL 2 instead of Hyper-V option on the Configuration page is selected. It depends on your choice of backend.
- Note in case your PC only supports one of the two options, you will not be able to select which backend to use
- Follow the given instructions on the installation wizard to authorize the installer and complete the installation
- When the installation is done, click Close to complete the installation process.
Note!
If your admin account is different from your user account, you must add the user to the docker-users group.
- Run Computer Management as an administrator and navigate to Local Users and Groups > Groups > docker-users. Right-click to add the user to the group. Log out and log back in for the changes to take effect.
Installing from the CLI:
Please ensure Docker Desktop Installer.exe is available locally on your machine. If yes, then type the following command in a terminal. Make sure you are in the root folder where the installer file exists.
"Docker Desktop Installer.exe" install
In case you use PowerShell you should type
Start-Process '.\win\build\Docker Desktop Installer.exe' -Wait install
The install command accepts the following arguments :
- --quiet: suppresses information output when running the installer
- --accept-license: accepts the Docker Subscription Service Agreement now, rather than requiring it to be accepted when the application is first run
- --allowed-org=<org name>: requires the user to sign in and be part of the specified Docker Hub organization when running the application
- --backend=<backend name>: selects the backend to use for Docker Desktop, hyper-v or wsl-2 (default)
Note!
In case your admin account is different from your user account, you must add the user to the docker-users group:
net localgroup docker-users <user> /add
Now that the installation process has been completed, its time to validate the same
Start the Docker On Your Machine :
Start Docker Desktop
To start Docker Desktop
- Search for Docker, and select the Docker Desktop menu option in the search results.
- Accepts the SLA terms & conditions
Note!
If you do not agree to the updated terms, the Docker Desktop application will close and you can no longer run Docker Desktop on your machine. You can choose to accept the terms at a later date by opening Docker Desktop.
3. When the initialization is complete, you can see Quick Start Guide UI as seen in the image below
You can skip it for the time being and move forward. You will be able to view the docker dahsboard. This shows you have successfully installed the docker desktop!.
If you want to install docker desktop on the Linux system, you can easily do so by following the instructions given in the below-given link.
Here is the installation link —
Install Docker Desktop on Linux
Welcome to Docker Desktop for Linux. This page contains information about system requirements, download URLs, and…docs.docker.com
Docker Desktop release notes:
When you are installing Docker desktop fresh or want to update, do keep a close eye on these release notes that are frequently updated and shared on Docker's official web portal. Here is the link-
Docker Desktop release notes
Estimated reading time: 31 minutes This page contains information about the new features, improvements, known issues…docs.docker.com
This comprises the new features, improvements, known issues, and bug fixes in Docker Desktop releases.
Quick Workshop To Get You Started
Now that we are done with the installation it's time to play with the docker desktop. We will learn in this demo a few of the docker commands like
- docker run
- docker push
- docker pull
- docker build
We will see the pushed docker image in our docker hub public repo. So before we start please sign in to your docker desktop, you need to have an account with docker hub, if not please visit here-
Docker Hub Container Image Library | App Containerization
Edit descriptionhub.docker.com
Firstly, signup. Once you have created the account go to the docker desktop icon and sign-up with the same. Once you signup you will see the below-given screen
1. Docker Run:
Open your terminal and type this command-
$ docker run hello-world
When you type there may be a high probability that the image with this name would not be present locally, but don’t worry docker understands this as a default thing so it will look for the docker image with this name in their docker hub public repo and will take a pull to download the same as shown in the image below.
Output:
You can clearly see that the docker run command looked for the image and as it didn’t find the same, took the pull from the hub.
So now when you again run the docker run command you will see that it responded with the message -
“Hello from the Docker!”
2. Listing all docker images :
When you key in this command you can see the list of the Docker images that exist in your local system, which can also be seen in your docker desktop dashboard, here is how it looks in my docker dashboard.
3. Docker ps command:
The ‘docker ps’ is a Docker command to list the running containers by default
$ docker ps
When typed this command this, you can see in the output none of container images are in a running state
But if you want to list all the containers, including stopped once? We can do that by adding --all option.
$ docker ps - all
I have created on the image, docker/getting-started, let’s see if it is running state or not
If we type docker ps again let's see what happens
$ docker ps
Now you can see that our latest pulled image docker/getting-started is in a running state.
4. Docker stop command:
To stop a container, use the docker stop command with either the container id or container name. We may stop a container if we want to change our docker run command.
Here we will stop our docker/getting-started container whose id is “6fa658d60902”
$docker stop 6fa658d60902
Now when we run the ps command after running docker stop, we can see that now our docker/getting-started has stopped.
5. Docker restart Command:
As can be seen from the above image, after we ran the docker restart command using the command-
$docker stop 6fa658d60902
and again typed docker ps command we get our docker/getting-started container up and running again stopped.
6. Docker Push Command:
If you want to push your Docker image to any public repository like the docker hub, you can use the docker push command.
Let’s create a public repo in the docker hub. So go to docker and sign-in
Once you give a repo name and click a create button, you will see the following output UI
Our repo with name pramdemo/demorepo is created, also, the command which will be required to push to this new repo is given on the right side-
“docker push pramdemo/demorepo:tagname”
Let’s see how we can push our locally existing docker images to this docker hub repo now.
When you type
$docker push pramdemo/demorepo
it will flag an error because no such image exists with the tag pramdemo/demorepo
Let’s tag our local image docker/getting-started and try to push the same to the docker hub repo
$ docker tag docker/getting-started pramdemo/demorepo
Now that we have the tagged image ready let’s try to push the same
$ docker push pramdemo/demorepo
woohoo! the image got pushed, let. check the same in our docker hub repo
You can see in the docker hub tag section the image got pushed.
This way you can code all your app create a docker image using dockerfile, and push the same to the docker hub publicly or privately. Once this is done your image will be ready to be pulled by any CI/CD pipeline or by any of your team members.
6. Docker Pull Command:
Now that your image is pushed in your docker hub repo you can anytime take a pull of the same in your local machine and get started. let’s see how it works.
If you carefully see the pushed image you will also get a pull command that one can use to take a pull. In this case the command is
$ docker pull pramdemo/demorepo:latest
the output:
We can see from the CLI output our latest image got pulled successfully.
7. Docker remove Command:
If you wanna get rid of unwanted images from your repo you can do so by command
docker rmi it removes images by their ID.
To remove the image, you first need to list all the images to get the Image IDs, Image names, and other details.
Let’s get the image id of docker/getting-started
We can see that docker/getting-started has the image id 157095baba98
So if we type
$ docker rmi 157095baba98
Output:
We got an error as one of the containers is running which is using this image, so we need to first stop the container or we can also enforce the deletion by using -f flag, let’s do the same and see the outcome
$docker rmi 157095baba98 -f
output:
We can see that our image docker/getting-started that had the image id 157095baba98 got deleted. When we typed the command
we can see that the all the images with the ID 157095baba98 got removed
Takeaways
We have comprehensively covered the docker and docker desktop journey and can see how magical this tool is. We learned the fundamentals of
- Docker
- Docker objects
- Docker architecture
- What & Why of Docker Desktop tool
- Installation of Docker on Windows and MAC systems
Then we ran through a quick demo workshop to see a few of the popular docker commands in action.
So what we learned from this, well here are a few key learnings as a takeaway
- Docker is a go-to tool for any big enterprises or small startups to ensure they are building, running, testing, and shipping their binaries fast
- If you are looking for a smart collaboration tool for development docker has to be a part of your arsenal to scale those efforts, especially when you are looking to implement micro-services as a part of your DevOps culture
To learn more about DevOps you can check one of the best courses for DevOps
- Docker supports docker-compose & Kubernetes which helps you to orchestrate your containerized apps and deploy them to the K8S cluster at scale.
Want to learn more about Docker and Kubernetes, you can subscribe to this exclusive course called docker and kubernetes online training.