Saturday, July 6, 2019

Docker Overview



What is Docker?
  • Docker is a platform for developers and sysadmins to develop, deploy and run applications with containers
  • Docker is standard for Linux containers
  • A "Container" is an isolated runtime inside of Linux
  • A "Container" provides a private machine-like space under Linux.
  • Containers will run under any modern Linux Kernel

Why Docker?
  • Faster delivery of your applications
  • Deploy and scale more easily
  • Get higher density and run more workloads
  • Faster deployment makes for easier management

What Containers can?
  • Have their own process space
  • their own network interface
  • 'Run' processes as a root (inside the container)
  • Have their own disk space (can share with the host too)
What is the difference between Virtual Machine (VM) and Container?


a) Virtual Machine:
Historically, as server processing power and capacity increased, bare metal applications weren’t able to exploit the new abundance in resources. Thus, VMs were born, designed by running software on top of physical servers to emulate a particular hardware system. A hypervisor, or a virtual machine monitor, is software, firmware, or hardware that creates and runs VMs. It’s what sits between the hardware and the virtual machine and is necessary to virtualize the server.
Within each virtual machine runs a unique guest operating system. VMs with different operating systems can run on the same physical server—a UNIX VM can sit alongside a Linux VM, and so on. Each VM has its own binaries, libraries, and applications that it services, and the VM may be many gigabytes in size.

b) How containers differ from VM?
Containers don't have guest operating system (compared to VM) and they sit on top of a physical server and its host operating system (OS) — for example, Linux or Windows. Each container shares the host OS kernel and, usually, the binaries and libraries, too. Shared components are read-only. Containers are thus exceptionally “light”—they are only megabytes in size and take just seconds to start, versus gigabytes and minutes for a VM.

Docker Terminology:
Docker Image – is an executable package that includes everything needed to run the application – code, a runtime, libraries, environmental variables and configuration files. Kind of like a JAR or WAR file in Java
Docker Container - the standard runtime instance of the image. Effectively a deployed and running Docker image. You can see the list of running continers using the command – docker ps. Like a Spring Boot Executable Jar
Docker Engine - the code which manages Docker stuff. Creates and runs Docker containers

What is Docker Engine?

Docker Engine is a client-server application with these major components:
A server which is a type of long-running program called a daemon process (the dockerd command).
A REST API which specifies interfaces that programs can use to talk to the daemon and instruct it what to do.
A command line interface (CLI) client (the docker command). The CLI uses the Docker REST API to control or interact with the Docker daemon through scripting or direct CLI commands. Many other Docker applications use the underlying API and CLI.
The daemon creates and manages Docker objects, such as images, containers, networks, and volumes.


Explain 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.
a) The Docker daemon:
  • The Docker daemon (dockerd) 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.
b) The Docker client:
  • The Docker client (docker) 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.
c) Docker registries:
  • A Docker registry stores Docker images. Docker Hub is a public registry that anyone can use, and Docker is configured to look for images on Docker Hub by default. 
  • You can even run your own private registry. 
  • If you use Docker Datacenter (DDC), it includes Docker Trusted Registry (DTR).
  • When you use the docker pull or docker run commands, the required images are pulled from your configured registry. 
  • When you use the docker push command, your image is pushed to your configured registry.

What are the various Docker Edition’s available?

Docker has two editions: 
1) Docker Enterprise 
2) Docker Community Edition

What is Docker Enterprise Edition?
  • Announced on March 2nd 2017
  • Enterprise class support provided with paid subscribption from Docker Inc
  • CaaS (Container as a Service) platform
  • Quarterly Releases
  • Backported patches for 1 year
  • Certified Infrastructure
What is Docker Community Edition?
  • Free Docker edition for developers and operations
  • Monthly 'edge' release with latest features
  • Quarterly releases for operations
How to download Docker?

Docker now comes with full Kubernetes integration. You can download the respective Docker based on your Operating System - https://docs.docker.com/engine/installation/

How to test the Docker installation?

Once the Docker is installed, you can test the Docker installation with the following steps:
1. Run the following command to print the Docker version installed
docker --version 
2. Run the following command to to view more details about your Docker installation:
docker info
3. Run the following command to test if the installation works by running the simple Docker image, hello-world:
docker run hello-world
4. Run the following command to list the docker images
docker image ls or docker ps