What is Docker?
Docker was first released in March 2013. It is developed by Solomon Nykes and Sebastian Pahl.
Docker is a set of "platform as a service" that uses operating system-level virtualization. Whereas VMware uses hardware-level virtualization.
Docker is an open-source, centralized platform designed to create, deploy and run applications.
Docker uses a container on the host OS to run applications. It allows applications to use the same Linux kernel as a system on the host computer, rather than creating a whole virtual OS. Docker works only on the Linux kernel.
We can install Docker on any operating system but the Docker engine runs natively on Linux distribution.
Docker is written in the "Go" language. It is a tool that performs OS-level virtualization, also known as containerization.
Before Docker, many users face the problem that a particular code is running in the developer system but not in the user's system.
Advantages of Docker
Less Cost.
No pre-allocation of RAM.
CI Efficiency- Docker enables you to build a container image and use that same image across every step of the deployment process.
It is lightweight.
It can run on physical hardware/virtual hardware or the cloud.
We can reuse the image.
It takes very less time to create the container.
Disadvantages of Docker
Docker is not a good solution for application that requires rich GUI.
Docker does not provide platform compatibility. This means if the application is designed to run in a docker container on Windows then it can't run on Linux or vice versa.
The docker is suitable when the development O.S. and testing O.S. same. If OS is different we should run VM.
No solution for data recovery and backup.
Architecture of Docker
a. Docker Daemon-
Docker engine.
Docker daemon runs on the host OS.
It is responsible for running containers to manage docker services.
Doctor demons can communicate with each other
b. Docker Client-
Docker users can interact with the docker daemon through a client CLI.
The Docker client uses commands and REST API to communicate with the Docker daemon.
When a client runs any service command on the docker client terminal, the client terminal sends these docker commands to the docker daemon.
Docker clients can communicate with more than one daemon.
c. Docker Host-
- Docker Hosts are used to provide an environment to execute and run applications. It contains the docker daemon, images, containers, networks and storage.
d. Docker hub/registry-
Docker Hub manages and stores the docker images.
There are 2 types of registry
Public registry- called Docker Hub
Private registry- It is used to share images within the enterprise.
e. Docker images-
Docker images are the read-only binary templates used to create a docker container.
Single file with all dependencies and configurations required to run a program.
Ways to create an Image
take an image from the docker hub.
Create an image from the docker file.
Create an image from existing docker containers.
f. Docker Container
container holds the entire package that is needed to run the application. Or in other words, we can say that the image is a template and the container is a copy of that template.
The container is like a VM.
Images become containers when they run on the docker engine.
Commands in Docker
To see all images present in your local machine.
docker images
To find out the image in the docker hub.
docker search jenkins/ubuntu
To download images from the docker hub to the local machine
docker pull jenkins/centos
To give a name to the container
docker run -it --name <container name> ubuntu /bin/bash
To check if the service is starting or not.
service docker status
To start the container.
docker start <container name>
To go inside the container.
docker attach <container name>
To see all containers.
docker ps-a
To see only running containers.
docker ps
To stop the container.
docker stop <container name>
To delete the container.
docker rm <container name>
Docker version.
docker -v
To start docker.
service docker start