Docker

Docker

What is Docker?

  1. Docker was first released in March 2013. It is developed by Solomon Nykes and Sebastian Pahl.

  2. Docker is a set of "platform as a service" that uses operating system-level virtualization. Whereas VMware uses hardware-level virtualization.

  3. Docker is an open-source, centralized platform designed to create, deploy and run applications.

  4. 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.

  5. We can install Docker on any operating system but the Docker engine runs natively on Linux distribution.

  6. Docker is written in the "Go" language. It is a tool that performs OS-level virtualization, also known as containerization.

  7. 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

  1. Less Cost.

  2. No pre-allocation of RAM.

  3. CI Efficiency- Docker enables you to build a container image and use that same image across every step of the deployment process.

  4. It is lightweight.

  5. It can run on physical hardware/virtual hardware or the cloud.

  6. We can reuse the image.

  7. It takes very less time to create the container.

Disadvantages of Docker

  1. Docker is not a good solution for application that requires rich GUI.

  2. 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.

  3. The docker is suitable when the development O.S. and testing O.S. same. If OS is different we should run VM.

  4. No solution for data recovery and backup.

Architecture of Docker

a. Docker Daemon-

  1. Docker engine.

  2. Docker daemon runs on the host OS.

  3. It is responsible for running containers to manage docker services.

  4. Doctor demons can communicate with each other

b. Docker Client-

  1. Docker users can interact with the docker daemon through a client CLI.

  2. The Docker client uses commands and REST API to communicate with the Docker daemon.

  3. When a client runs any service command on the docker client terminal, the client terminal sends these docker commands to the docker daemon.

  4. Docker clients can communicate with more than one daemon.

c. Docker Host-

  1. 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-

  1. Docker Hub manages and stores the docker images.

  2. 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-

  1. Docker images are the read-only binary templates used to create a docker container.

  2. Single file with all dependencies and configurations required to run a program.

Ways to create an Image

  1. take an image from the docker hub.

  2. Create an image from the docker file.

  3. Create an image from existing docker containers.

f. Docker Container

  1. 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.

  2. The container is like a VM.

  3. Images become containers when they run on the docker engine.

Commands in Docker

  1. To see all images present in your local machine.

    docker images

  2. To find out the image in the docker hub.

    docker search jenkins/ubuntu

  3. To download images from the docker hub to the local machine

    docker pull jenkins/centos

  4. To give a name to the container

    docker run -it --name <container name> ubuntu /bin/bash

  5. To check if the service is starting or not.

    service docker status

  6. To start the container.

    docker start <container name>

  7. To go inside the container.

    docker attach <container name>

  8. To see all containers.

    docker ps-a

  9. To see only running containers.

    docker ps

  10. To stop the container.

    docker stop <container name>

  11. To delete the container.

    docker rm <container name>

  12. Docker version.

    docker -v

  13. To start docker.

    service docker start