Docker Basics – DEV Community

Docker Basics – DEV Community

What Docker is trying to resolve

1.Application solution works properly in local environment but when moving to different environment like Test/ Prod – Will see performance degradation
2.It works fine in my machine and its not working in test/ prod machines – May be some configurations may be missed while moving to test/prod machines

Docker

  • It allows to have sealed Air-tight containers
  • It wraps up the entire code
  • It works fine when moving from one environment to other environment
  • Docker packaged with code, dependencies ,config, process, OS Chunks

Docker is an open-source technology used mostly for

  • Developing
  • Shipping
  • Running Applications

Why Docker

Image description

Image description

  • Docker is an OS-level virtualization software platform that enables developers and IT administrators to create, deploy and run applications in a Docker with all their dependencies.
  • Docker container is a lightweight software package that includes all the dependencies (framework, libraries, etc.) required to execute an application

What is Docker
Docker is a tool which is used to automate the deployment of applications in lightweight containers so that applications can work efficiently in different environments.

  • Multiple containers run on the same hardware
  • Maintains isolated applications
  • High productivity
  • Quick and easy configuration

What is Containerisation
It is the process of packing the application and all its dependencies to execute them in an efficient and hassle-free way across different environments. A single unit of this bundled package is known as a Container.

Image description

How does Docker Work

Image description

  • Docker Engine or Docker is the base engine installed on your host machine to build and run containers using Docker components and services.
  • It uses a client-service architecture.
  • Docker Client and Server communicate using Rest API.

What happens at this point

  • Docker client is a service which runs a command. The command is translated using REST API and is set to the Docker Daemon (server).
  • Then, Docker Daemon checks the client request and interacts with the operating system in order to create or manage containers.

Components of Docker

Image description

Docker Architecture

Image description

References : https://docs.docker.com/get-started/overview/

Docker Client and Server

  • Docker Works in a client-server architecture
  • The client sends the control commands to the Docker Daemon through a REST API.
  • Docker Daemon is responsible for building, running and distributing the containers.
  • The Client and Daemon can be on the same system or the client can connect to a remote Daemon.

  • Docker Client is accessed from the terminal and a Docker Host runs the Docker Daemon and registry.

  • A user can build Docker Images and run Docker Containers by passing commands from the Docker Client to Docker Server

Note : The machine running the docker server is called as Docker Host

Docker Image

  • Docker Image is a template with instructions, which is used for creating Docker Containers
  • A Docker Image is build using a file called Docker File
  • Docker Image is stored in a Docker Hub or in a repository (like registry.hub.Docker.com)

Note : A Docker File is a text file which contains commands for building a Docker Image

Docker Container

  • Numerous Docker Container run on the same infrastructure and share operating system(OS) with its other containers
  • Here each application runs in isolation

Image description

Docker Desktop
Docker Desktop is an easy-to-install application for your Mac, Windows or Linux environment that enables you to build and share containerized applications and microservices.
Docker Desktop includes the Docker daemon (dockerd), the Docker client (docker).
for more information Docker Desktop

Installing Docker desktop : Download

Docker Registry

  • Docker Registry is an open source server-side service used for hosting and distributing images
  • Docker also has its own default registry called Docker Hub
  • Here,images can be stored in either public or private respositories
  • Pull and Push are the commands used by users in order to interact with a Docker Registry
  • In order to build a container, pull command is used to get a Docker Image from the Docker repository

Docker pull <image>:<tag> :pulls an images from Docker Registry

  • With push command, a user can store the Docker Image in Docker Registry

Docker push <image>:<tag> :pushes an image to Docker Registry

Virtual Machine Vs Docker

Image description

Image description

Image description

Container Lifecycle
A new created container can be in one of six states:

  • Created
  • Running
  • Paused
  • Stopped
  • Restarted
  • Dead

Docker Commands

  • docker run : Creates a container from an image
  • docker start : Starts an already stopped container(s)
  • docker stop : Stop an active container
  • docker build :Builds a docker image from a docker file
  • docker pull : Pulls re-created images from a specific repository
  • docker export : Exports container filesystem to a .tar achieve file
  • docker images : List the docker images currently on the local system
  • docker search : Searches repository for the specified image
  • docker ps : Lists all active containers running on the system
  • docker kill : kills an active container without any grace period to shut down its processes
  • docker commit : Creates a new image out of an already active container
  • docker login :Command to login to docker hub repository

Conclusion : Discussed about the basics of docker vs vm, docker architecture and docker commands.

💬 If you enjoyed reading this blog post and found it informative, please take a moment to share your thoughts by leaving a review and liking it 😀 and follow me in linkedin


Source link

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker