Time Pass Logo
Tech

Docker Demystified: Understanding Containers, Images, and Architecture

Learn the basics of Docker containers and images. Explore the Docker architecture and discover how it simplifies application development and deployment.

 

Dockers enables developers to develop, deploy, and run applications in containers.

In this way, Docker allows to bundle an application along with its environment, all the dependencies, so that it can run on any system that has Docker running. This leads to a more manageable and scalable applications, while eliminating issues from development to productionBy sharing the same container images developers can create the same environments for development, testing, and production.

Javascript Interview Preparation Course  : Link
Use Discount Coupon: PIYUSHAM19615


Docker Visualization

 

Problems

  1. Every developer in the team must have the same configurations.

  2. Whenever new dev joins the team, a whole bunch of applications needs to be installed with exact identical versions.

  3. You need to replicate your dev environment to the production server to ensure smooth working

Docker Architecture 

Docker Architecture

 

Docker Images

In Docker, an image is a lightweight, standalone, and executable software package that includes everything needed to run a piece of software, including the code, runtime, libraries, environment variables, and system tools. It is the fundamental building block of Docker containers.

or

Image is the just the OS which runs on the container. 

docker pull ubuntu (these images coming from docker hub)

 

Docker Container

Containers are lightweight, portable, and self-contained environments that can run anywhere, making it easy to develop and deploy applications across different environments such as development, testing, staging, and production.

 

Base Image

We need the OS where we will install our softwares and run them. So we can use ubuntu, MacOS, Windows. So these images we call base image 
By combining the base image (ubuntu) and other softwares like node js, mysql you can build a new image which can be used by another container. 

image name you can give like : piyushdev and then can run this image in container like 
docker run -it piyushdev. So it will have ubuntu and other related packages installed 

 

Docker Commands

 

Working with containers:

  • docker run <image>: creates and starts a container based on the specified image. Example: docker run nginx

  • docker start <container>: starts a stopped container. Example: docker start my-container

  • docker stop <container>: stops a running container. Example: docker stop my-container

  • docker rm <container>: removes a stopped container. Example: docker rm my-container

  • docker ps: lists all running containers. Example: docker ps

  • docker ps -a: lists all containers, including stopped ones. Example: docker ps -a

  • docker logs <container>: displays the logs of a container. Example: docker logs my-container

  • docker exec <container> <command>: runs a command inside a running container. Example: docker exec my-container ls

  • docker inspect <container>: displays detailed information about a container. Example: docker inspect my-container

     

Working with images:

  • docker pull <image>: downloads an image from a registry. Example: docker pull ubuntu

  • docker build <path>: builds an image from a Dockerfile. Example: docker build.

  • docker tag <image> <repository>:<tag>: tags an image with a repository and tag. Example: docker tag my-image my-repo:1.0

  • docker push <repository>:<tag>: pushes an image to a registry. Example: docker push my-repo:1.0

  • docker rmi <image>: removes an image. Example: docker rmi my-image
     
     

Docker
Docker Images
Docker Container
trending new technologies

Read More