Skip to main content

Command Palette

Search for a command to run...

Everything about Docker

Day 16 #90daysofdevops challenge

Updated
6 min read
Everything about Docker
Y

Hi there! My name is Yashswini and I'm a Linux Engineer with 3 years of experience in automation, continuous integration, and deployment. My expertise lies in DevOps and Cloud Computing with a focus on AWS. I have hands-on experience in various tools and technologies related to infrastructure automation, managed services, containerization, and monitoring and logging. I have a passion for troubleshooting and resolving issues and I'm always eager to learn and explore new technologies

1 . What is Docker?

  • Docker simplifies the process of packaging, deploying, and running applications by using containers. It helps ensure that your application works consistently across different environments, making it easier to develop and deploy software.

  • Docker was first released in March 2023. It is developed by Solomon Hykes and Sebastian Paul

  • Docker is open source centralized platform designed to create deploy and run applications

  • Docker is a tool that provides os level of platform virtualization also known as containerization

  • Docker also makes it easy to share and distribute your containers. There's a place called Docker Hub where you can store and find containers created by others

2 . Use of Docker

  • With Docker, you can package your application once and deploy it consistently across different environments

  • Docker is commonly used in microservices-based architectures.

  • Docker is often integrated into CI/CD pipelines to automate the building, testing, and deployment of applications.

  • Docker enables easy scaling of applications by running multiple instances of containers.

  • Docker's portability makes it ideal for hybrid and multi-cloud environments

3. Advantages of Docker

  • Cost Saving

  • Security

  • Rapid Deployment

  • Simplicity and Faster Configurations

  • Continuous Integration

4. Disadvantages of Docker

  • Data in the container

  • Provide cross-platform compatibility

  • Run applications with graphical interfaces

5. Components of Docker

  • Docker Image :

    An image is a read-only template used to create containers. It contains all the instructions and dependencies required to run an application.

  • Docker Daemon :

    the Docker daemon (dockerd) It runs as a background process on the host machine, managing container lifecycle, images other aspects essential for running Docker-based applications.

  • Docker Client :

    The Docker client provides a straightforward and convenient way to interact with the Docker daemon, enabling users to manage and control their Dockerized applications, images, and containers efficiently.

  • Docker Host :

    Docker host is used to provide an environment to execute and run applications. It contains the docker daemon, docker images, containers, networks, and storage

  • Docker Engine :

    The Docker Engine is the runtime environment for containers. It consists of the Docker daemon (dockerd) running on the host machine and the Docker CLI (docker) used to interact with the daemon. The Docker Engine creates, manages, and runs containers based on Docker images.

  • Docker Hub / Docker Registry :

    Docker Registry is a centralized repository for storing and sharing Docker images. Docker Hub is the default public registry provided by Docker, housing a vast collection of images. Organizations can also set up private registries to store their own images securely.

  • Docker Container :

    Docker uses containers to package and isolate applications. A container is like a lightweight virtual machine that includes all the necessary dependencies, libraries, and code to run an application. Containers are isolated from each other and the underlying host system, ensuring consistent and reliable application execution.

  • Dockerfile :

    A Dockerfile is a text file that contains a set of instructions for building a Docker image. It defines the base image, adds files, installs software packages, sets environment variables, and more. Dockerfiles are used to automate the image creation process

    Some Advance components will discuss them detail in the next blog ...

  • Docker Compose :

    Docker Compose is a tool for defining and running multi-container applications. It uses a YAML file to specify the services, networks, and volumes required for an application

  • Docker Swarm :

    Docker Swarm or container orchestration and Kubernetes are popular container orchestration platforms. They help manage and scale containers across multiple hosts or clusters, providing features like load balancing, service discovery, fault tolerance, and auto-scaling. Container orchestration simplifies the deployment and management of containerized applications at scale.

4. Difference Between Virtualization and Docker

DockerVirtualization
It boots in a few seconds.It takes a few minutes for VMs to boot.
Pre-built docker containers are readily available.Ready-made VMs are challenging to find.
Docker has a complex usage mechanism consisting of both third-party and docker-managed tools.Tools are easy to use and more straightforward to work with. third-party.
Limited to Linux.Can run a variety of guest OS.
Dockers make use of the execution engine.VMs make use of the hypervisor.
It is lightweight.It is heavyweight.
Host OS can be different from container OS.Host OS can be different from guest OS.
Can run many docker containers on a laptop.Cannot run more than a couple of VMS on an average laptop.
Docker can get a virtual network adapter. It can have separate IPs ad Ports.Each VMS gets its virtual network adapter.
Sharing of files is possible.Sharing library and files are not possible.
Lacks security measures.Security depends on the hypervisor.
A container is portable.VMS is dependent on a hypervisor.
It allows running an application in an isolated environment known as a containerIt provides easiness in managing applications, recovery mechanisms, and isolation from the host operating system

5 . Docker installation and some command

  • Docker Installation :

#sudo apt install docker.io -y

Sudo apt indtall docker.io -y

after installation, we need to add the user (ubuntu) into the docker group and take exit from the session and open a new one

  • Docker pull image

The 'docker pull' is a Docker command to download a Docker image or a repository locally on the host from a public or private registry.

  • To give a name to the docker container and run and using it ->interactive mode and direct to the terminal

    docker run -it --name (container_name ) (image_name)

  • Use the docker inspect command to view detailed information about a container or image.

docker inspect <container_name or container id>

  • Use the docker port command to list the port mappings for a container.

    There are no ports available.

    docker port <container_id>

  • Use the docker stats command to view resource usage statistics for one or more containers

    docker stats <container_id>

  • Use the docker top command to view the processes running inside a container

docker top <container _id>

  • Use the docker save command to save an image to a tar archive.

    Save the Ubuntu image by giving the present working directory path i.e.

    docker save <image_id> > <present dir path>

  • Use the docker load command to load an image from a tar archive.

This is some basic about docker will find more about it in next blog

Thanks for reading.....