What is Docker?
Docker is a container platform that allows you to build, test, and deploy applications quickly. It is a containerization platform that allows developers to package applications and their dependencies into a standardized unit called a container.
Why Docker?
Using docker can help us in various ways we can deploy applications on containers that make it easier for them to be deployed, scaled, perform rollbacks, and identify issues. The isolation of containers guarantees that applications run in their own environment, preventing conflicts and streamlining deployment. We can use Docker for Microservices, Data Processing, Continuous Integration and Delivery, and Containers as a Service.
Docker Architecture
Docker uses a client-server architecture. The Docker client talks to the Docker daemon, which does the heavy lifting of building, running, and distributing your Docker containers. The Docker client and daemon can run on the same system, or you can connect a Docker client to a remote Docker daemon. The Docker client and daemon communicate using a REST API, over UNIX sockets or a network interface.
The Docker daemon
The Docker daemon listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. A daemon can also communicate with other daemons to manage Docker services.
The Docker client
The Docker client is the primary way that many Docker users interact with Docker. When you use commands such as docker run
, the client sends these commands to dockerd
, which carries them out. The docker
command uses the Docker API. The Docker client can communicate with more than one daemon.
Docker registries
This is where Docker images are stored. Docker Hub is a public registry that anyone can use. When you pull an image, Docker by default looks for it in the public registry and saves the image on your local system on DOCKER_HOST. You can also store images on your local machine or push them to the public registry.
Dockerfile
It describes the steps to create a Docker image. It’s like a sort of algorithm that should be followed to create a docker image. This file can be used to create a Docker Image. These images can be pulled to create containers in any environment. These images can also be stored online at docker hubs. When you run docker image you get docker containers. The container will have the application with all its dependencies.
Create a file named ‘Dockerfile’
By default on building, docker searches for ‘Dockerfile’
$ docker build -t myimage:1.0 .
During building of the image, the commands in RUN section of Dockerfile will get executed.
$ docker run ImageID
The commands in CMD section of Dockerfile will get executed when you create a container out of the image.
FROM ubuntu MAINTAINER kirti kamal <kirti@gmail.com> RUN apt-get update CMD [“echo”, “Hello World”]
Docker Compose File
Docker Compose files can be used to run multiple services at once and are great once you have many microservices as part of your application.
Docker images
It is an immutable snapshot or a template of a file system with all the necessary dependencies to execute an application. Docker images are the building blocks used to create and run Docker containers.
A docker image is a snapshot of the filesystem + some metadata
Image management commands
What is a container?
A container is an isolated environment for your code. This means that a container has no knowledge of your operating system or your files. It runs on the environment provided to you by Docker Desktop. Containers have everything that your code needs in order to run, down to a base operating system. You can use Docker Desktop to manage and explore your containers. This is the place where your application is running.
Lifecycle of a Docker Container
Conclusion
In the containerized universe of Docker, we've uncovered a revolutionary approach to software development and deployment. Docker's simplicity in creating, managing, and running containers has reshaped the way we build and ship applications.
For further exploration and mastery, check out the official Docker documentation https://docs.docker.com/