What is Docker?
Docker is software used by developers to develop, deploy, and run application programs on objects called containers. It implements system-level virtualization, which is also called "containerization", where the OS kernel offers a separate user-space instance aka “containers”, to deploy programs.
Let’s deep dive to understand what exactly are these Containers and how does a Docker work. The containers are a bundle of application resources that provide a virtual platform for the programs to run. They resemble a real computer, for a program running on it; however, only a set of resources and devices will be assigned to them from the host OS Kernel. Only the programs running on them will be able to access these resources.
Multiple containers can simultaneously run on a host Kernel. Each container will be isolated completely from other containers on the Docker. This isolation enhances the usability of Docker, allowing multiple, independent programs to run on a Docker simultaneously.
Dockers provide you with tools and platforms to manage the complete lifecycle of the containers. Owing to a number of advantages, Containerization has become very popular.
- Flexible: Even the most complex programs can be containerized.
- Lightweight: As it shares the host resources without a hypervisor(which is an overhead in case of Virtual Machine)
- Interchangeable: You can install the new updates in a flash.
- Portable: Platform dependency is absent. You can build locally and deploy on cloud and use it anywhere.
- Scalable: You can replicate containers and distribute them.
- Stackable: You can stack services.
Components of Docker
Docker is typically made of the following 3 components:
Docker is a software that runs at system-level virtualization. In an environment like this, where operating systems are multitasking, a computer program called daemon will be running as a background process.
In Docker programming, dockerd represents the daemon, which manages the Docker containers. It listens to the containers via Docker engine API and performs instructions accordingly. The client program on Docker is called docker, which provides a command line interface for the users to instruct the Docker daemons.
An object in Docker, is a bundle of all the entities required for the Docker to run an application. There are 3 main entities comprising objects. They are Containers, Images, and Services.
- Images: Docker images are the read-only templates which are used to create containers. An image is an executable file that encapsulates all the resources required to run an application, like the code, environment variables, runtime libraries, and configuration files. They, also help in application storage and shipping.
- Containers: This is the runtime object of an image. It is what an image when active is called. It is basically the user-space which allows the application to execute smoothly.
- Service: Docker Service is a piece of program that performs a task across the network, like video streaming, fetching data, or posting data. It is capable of scaling the containers across multiple Docker Daemons and stacking them up. This yields to "swarm", a set of interactive daemons managed by a Docker API.
[Related Page: Installing Docker To Mac, Windows, Oracle Linux 6 & 7 In Docker]
Docker Registries are the repositories of the Docker images. Docker clients use the registries to push or pull the images. Access to the registry can be made public or private. There are 2 major public registries of Docker, Docker Cloud and Docker Hub.
Docker Hub is the default registry used by clients to upload or download images. Docker Cloud enables you to connect to the existing cloud infrastructure like AWS, Azure or connect to GitHub, where you can push all your repositories to obtain cloud access to the images.
Docker follows the Client- Server Model. The Docker client called docker will communicate with docker for various operations. Docker daemon (dockerd) is responsible for managing the containers and their distribution. The Docker Daemon and the Docker Client communicate with each other with the help of REST API over a network interface or over UNIX sockets.
Details of Docker Architecture
Subscribe to our youtube channel to get new updates..!
Below is a brief introduction to each component of the architecture and the functionality associated with it. Each of the component contributes to the overall functioning of the Docker on a HOST.
The Docker Daemon
The Docker daemon is the mediator between the client, host, and the registries. It listens to the instructions from the Docker API. It manages the Docker objects, network, and volumes. It also communicates with other Docker daemons to handle the services across multiple daemons.
The Docker Client
The Docker client is the API through which the user interacts and instructs what has to be carried out on the application. For example, a simple command called docker run will execute the container program, where the daemon listens to the command, understands and executes the same. The Docker client can interact with more than one daemon.
The Docker Registries
Whenever a command like docker run or docker pull is executed, a call is made to the registry to pull the corresponding images while, docker push command adds the image to the Docker registry.
The call is generated by a client request to the Docker API. The API commands the Docker Daemon to service the request. This call is in turn made to the Repository to perform the action intended.
The Docker Containers
A container is an active image. It is generated from API by CLI instructions. A container can be moved, created, modified, run or deleted from the Docker. You can attach one or more networks, storage and other entities to a container. All the features of the container can be controlled, such as the level of isolation of its networks and storage from the other containers existing in the host system.
A container is defined just not by its image, but also the features adopted during its creation. While deleting a container, the changes made to its state will be deleted, if they are not stored in the persistent storage.
[Related Page: Security In The Docker]
The Docker Images
These are the read-only components from which containers are created. You can either create Docker Image or use from the existing images in the repository. In order to create an image, you have to create a Dockerfile with a simple syntax for defining the image of your requirement. Each command creates a layer in the image. If you change any instruction and rebuild, only those layers of the image will see the new changes.
The Docker Services
Services are mainly the containers in production. They are associated with scaling the containers across multiple daemons and managing them. This results in the swarm. Each swarm member is nothing but a daemon, which communicates and interacts with the remaining daemons through the docker API.
Docker service allows you to define the state required. For example, you can define the number of replicas of the service that needs to be available at a given point of time. By default, the services will be in the load-balanced state across all working daemons. Docker 1.12 and higher versions support swarm mode.
The Docker Files
When you want to build an image of your own, you instruct the Docker API to do so by writing a set of commands in Dockerfile. A Dockerfile contains all the possible commands that would build the required image automatically. The instruction, docker build, create an automated build that would execute several command-line instructions in succession.
Docker machine is a tool that allows you to install and configure the Docker Engine on the virtual hosts. It provides you with docker commands that help you manage the virtual hosts. You can use the Docker Machine to create the virtual hosts on your Mac, Windows, on cloud providers like Azure, AWS, or Digital Ocean or on your company network.
The docker commands will let you start, inspect, stop, and restart the virtual hosts. They also allow you to upgrade the Docker client and daemon. Initially, the Docker Machine was the only way to run the Docker on the Mac and Windows. However, post-Docker v1.12, native apps are available to run it on Mac and Windows.
Installing Docker is a simple process. Depending on your system configuration and OS version, you can download the corresponding package from the official Docker website. Details of the same are given below:
In order to install the supported version on your OS, Please visit https://docs.docker.com/install/
The above link guides you through installation process.
Test the Docker Installation
Once you are done with installation, run the following command, to verify if your Docker is installed with the latest version.
In order to test run a sample project on your Docker, execute the following command:docker run hello-world
This will download the simple hello-world image on your Docker.
To list the downloaded image, use the command:
docker image ls
This is a dry-run on your Docker to ensure that installation is done completely and your Docker is up and running. Now, you are all set to explore Docker more.
Basic Docker Commands
This is to help you with few basics commands to break the ice and get your hands get dirty on Docker.
Here is a list of few basic Docker commands:
- docker run – Runs the container (one or more).
- docker start – Starts the containers (one or more).
- docker stop – Stops the running containers (one or more).
- docker build – Builds an image from the Dockerfile.
- docker pull – Downloads an image from the registry.
- docker push – Uploads an image into the registry.
- docker export – Exports a container’s filesystem in tar format.
- docker exec – executes a command in a run-time container.
- docker search – Searches for images in Docker Hub.
- docker attach – Attaches to an active container.
- docker commit – Creates a new image from the Dockerfile.
Below displays a list of the uses and importance of Docker in different market areas.
Docker for Developers
Docker, as a software, is designed to enable both developers and system admins to work more efficiently. Hence it is made as a part of many DevOps toolchains. However, as a developer, all you need to know is how to execute and code certain command line instructions to develop your application and run it.
Docker is platform independent, and hence, you do not have to worry about the environment of support and deployment. There are already a number of applications up and running on Docker from where you can start to work. In order to start working, first, download Docker from the Docker official page..
Dockers for IT Operations
The lightweightedness of the Docker on the host is the most distinguishing point for Operations staff. It easily allows for the execution and management of different applications, simultaneously, in different isolated containers. This flexibility and reduced overhead, increase the efficiency of resource distribution in servers, leading to a lesser number of systems needed. This, in turn, reduces the cost.
Dockers for the Executive
Executives face the constant challenge of doing more with less in the ever-growing market. The demand to increase the output for a lesser number of resources and the reduced cost is what they are expected to deliver in every single business. In addition, adapting to the rapid changing IT Landscape, Dockers come as the solution.
Docker uses the containers as the packaging applications which render a much lighter and faster delivery model. It also allows for running multiple applications simultaneously, in different containers on a single host, irrespective of the host being VM or a physical machine. Besides, dockers also play a major role in DevOps, cloud strategy, and microservices.
Docker Enterprise is carefully designed to provide an efficient container platform that manages the Enterprise demand of running the business-critical applications, cutting edge micro-services, and Big Data applications.
Docker Enterprise gives the flexibility to evolve your application to any infrastructure like the cloud services (AWS, Azure, etc.), any operating system, and any orchestrator like Swarm or Kubernetes to match the needs of your organization.
List Of MindMajix Docker Courses: