DOCKER - Basics

  1. what is a container? Generally, a container is a bundle of applications and application libraries required to run your application with the minimum system dependencies.

  2. What is the difference between containers and virtual machines? Containers and virtual machines are both technologies used to isolate applications and their dependencies, but with some key differences:

FeatureContainersVirtual Machines (VMs)
ArchitectureShare the host OS kernelInclude a full OS instance
IsolationProcess-level isolationHardware-level isolation
Boot TimeUsually in secondsUsually in minutes
Resource UsageLightweight (only necessary libraries and binaries)Heavy (full OS and applications)
Use CaseMicroservices, rapid deployment, scalable systemsMonolithic applications, full OS testing
Deployment SizeSmall (megabytes)Large (gigabytes)
Startup TimeFast (seconds)Slow (minutes)
Host DependencyMust use the same OS kernel as the hostCan run a different OS than the host
Management ToolsDocker, KubernetesVMware, Hyper-V, VirtualBox
SecurityShares the host OS kernel, less isolationStrong isolation, each VM is a separate OS instance
Lifecycle ManagementEasier to create, deploy, and destroyMore complex management and maintenance
  1. What is docker? Docker is a containerization platform that helps to easily containerize applications. In simple words, containerization is a concept and Docker implements this concept.

  2. what are the docker components.? Docker has several core components that work together to facilitate containerization. Here’s a breakdown of the key Docker components:

ComponentDescription
Docker EngineCore part of Docker, responsible for creating and managing Docker containers. It consists of the Docker daemon, a REST API, and a CLI.
Docker DaemonBackground service running on the host that manages Docker images, containers, networks, and storage volumes.
Docker CLICommand-line interface that allows users to interact with the Docker daemon through commands.
Docker ImagesRead-only templates used to create Docker containers. They contain the application code, runtime, libraries, environment variables, and configuration files.
Docker ContainersLightweight, portable, and executable packages that run instances of Docker images. Containers share the host OS kernel.
DockerfileA text file containing instructions for building a Docker image. It specifies the base image and the steps to install dependencies and copy application code.
Docker HubA cloud-based registry service where Docker users can create, store, and distribute Docker images. It includes both public and private repositories.
Docker ComposeA tool for defining and running multi-container Docker applications. It uses a YAML file to configure the application’s services, networks, and volumes.
Docker SwarmNative clustering and orchestration tool for Docker. It allows users to create and manage a swarm of Docker nodes (servers) as a single virtual system.
Docker RegistryA storage and distribution system for Docker images. Docker Hub is a public registry, but private registries can also be set up.
Docker VolumeA method for persisting data generated and used by Docker containers. Volumes are managed by Docker and can be shared among multiple containers.
Docker NetworkEnables communication between Docker containers, whether on the same host or across different hosts. Docker provides several networking options, such as bridge, host, overlay, and macvlan.
  1. Explain the docker lifecycle with the commands used.

Docker Lifecycle and Key Commands

Lifecycle StageDescriptionDocker Commands
Build ImageCreate a Docker image from a Dockerfile.docker build -t myapp:latest .
Run ContainerCreate and start a container from an image.docker run -d --name myapp_container myapp:latest
List ContainersList running containers.docker ps
Stop ContainerStop a running container.docker stop myapp_container
Start ContainerStart a stopped container.docker start myapp_container
Remove ContainerRemove a stopped container.docker rm myapp_container
List ImagesView all available Docker images.docker images
Remove ImageDelete an image.docker rmi myapp:latest
Push ImageUpload an image to a registry (e.g., Docker Hub).docker push myusername/myapp:latest
Pull ImageDownload an image from a registry.docker pull myusername/myapp:latest
0
Subscribe to my newsletter

Read articles from krishna prasad kondra directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

krishna prasad kondra
krishna prasad kondra

Currently, Learning the ways of cloud and DevOps.