Day 16:Docker for DevOps Engineers.

Day 16:Docker for DevOps Engineers.

Table of contents

  • Docker is a tool that performs O.S.-level virtualization, also known as containerization or we can say it's a platform for building, shipping, and running applications in containers. Containers are lightweight, portable, and self-contained environments that provide a consistent runtime environment for applications, regardless of the underlying host operating system.

  • With Docker, developers can package their applications and all of their dependencies into a single container that can be easily deployed on any platform that supports Docker. This allows for greater flexibility and portability in application development and deployment.

Docker is made up of several components that work together to enable the creation, deployment, and management of containerized applications. Here are the main components of Docker:

  1. Docker daemon: The Docker daemon is the core component of Docker that runs on the host operating system and manages Docker images and containers. It listens for Docker API requests and handles the creation, deletion, and management of Docker objects such as images, containers, networks, and volumes.

  2. Docker client: The Docker client is a command-line tool that allows users to interact with the Docker daemon. Users can use the Docker client to build and manage Docker images, create and run Docker containers, and manage Docker networks and volumes.

  3. Docker images: Docker images are read-only templates that contain everything needed to run an application, including the application code, dependencies, libraries, and system tools. Docker images are built from Dockerfiles, which are plain text files that specify the instructions needed to build the image.

  4. Docker containers: Docker containers are running instances of Docker images. Each container runs in its own isolated environment, with its own file system and network interfaces. Containers can be created, started, stopped, and deleted using Docker commands.

  5. Docker registry: A Docker registry is a central repository for Docker images. Docker users can push and pull Docker images from a registry to share them with others or use them across different environments. Docker Hub is a popular public registry for Docker images, but users can also set up their own private registries.

  6. Docker network: Docker networks provide communication between Docker containers, as well as between Docker containers and the host system or other external systems. Docker supports several types of networks, including bridge networks, overlay networks, and host networks.

  7. Docker volumes: Docker volumes provide persistent storage for Docker containers, allowing data to persist even if the container is stopped or deleted. Docker volumes can be created and managed using Docker commands and can be used to share data between Docker containers or between a container and the host system.

Tasks

  • How to install the docker and version check.

    Docker can be installed in 3 ways:-

    1. With the help of the command line

    2. With the help of Package management

    3. With the help of Script (which is available on docker official website docs.docker.com/engine/install/ubuntu)

    4. Use the docker run command to start a new container and interact with it through the command line.

    5. The docker run the command is used to create and run a new Docker container based on a specified Docker image.

    sudo apt install docker.io
  • Use the docker run command to start a new container and interact with it through the command line.

    syntax:- sudo docker run -d <image-name or ID>

      docker run hello-world
    

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

      docker inspect hello-world
    

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

    syntax: docker port container-name(private_port)

  •     docker port jenkinscontainer
    

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

      docker stats
    

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

    syntax: sudo docker stats

      docker top jenkinscontainer
    

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

    syntax:- sudo docker save <image>

      docker save jenkins/jenkins --output jenkins-output.tar
    

These tasks involve simple operations that can be used to manage images and containers.

THANKYOU FOR READING BLOG ....