Day 16 - 90daysofdevops Challenge : Docker for DevOps Engineers
Docker

Day 16 - 90daysofdevops Challenge : Docker for DevOps Engineers

What is Docker and Why we need Docker?

==> Docker is a platform for building, running, managing, and distributing applications. It is based on the concept of containers, which are lightweight, self-contained environments that package an application and all of its dependencies together. This makes it easy to deploy and run applications consistently across different environments, from local development machines to production servers.

Docker is a popular tool for developers and DevOps teams because it provides several benefits, including:

  • Portability: Docker containers can run on any machine that has Docker installed, regardless of the underlying operating system. This makes it easy to move applications between different environments, such as from a developer's laptop to a production server.
  • Isolation: Docker containers are isolated from each other, which means that they cannot interfere with each other's resources or processes. This makes it a safe and reliable way to run multiple applications on the same machine.
  • Reproducibility: Docker containers are built from images, which are blueprints for containers. This makes it easy to create identical containers, which is important for testing and deployment.

Common Use Cases of Docker:

  • Web Applications: Deploying and managing web applications, including front-end and back-end components, in a consistent and scalable manner.
  • Micro services Architectures: Developing and deploying micro services-based applications, where each service is packaged as a separate Docker container.
  • Continuous Integration and Delivery (CI/CD): Automating the build, test, and deployment pipeline for applications using Docker containers and container orchestration tools.
  • DevOps: Enabling collaboration between development and operations teams to streamline the software delivery process.

Docker Architecture

--------------------------------------------------------------------------

Tasks

Use the docker run command to start a new container and interact with it through the command line. [Hint: docker run hello-world]

==> The docker run command is the primary command for launching containers in Docker. It takes a variety of options to specify the container's image, command, environment variables, ports, volumes, and other settings.

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

docker run -d hello-world latest        

docker run hello-world

docker run image-Name:Tag

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

==> The docker inspect command is used to inspect the details of a Docker object, such as a container, image, volume, network, or service. It provides detailed information about the object, including its configuration, state, and resources.

The basic syntax for the docker inspect command is as follows:

docker inspect OBJECT_ID...        
docker inspect object-ID

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

==> The docker port command is used to list all of the ports that are currently exposed for a container. It can also be used to check whether a specific port is exposed for a container.

The basic syntax for the docker port command is as follows:

docker port [CONTAINER_ID]        
docker port container-id

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

==> The docker stats command is used to display a live stream of container resource usage statistics. It provides information about the CPU, memory, network, and disk usage of all running containers.

The basic syntax for the docker stats command is as follows:

docker stats [OPTIONS] [CONTAINER...]        
docker stats container-id

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

==> The docker top command is used to display a list of running processes within a Docker container. It provides information about the process ID (PID), user ID (UID), command name, CPU usage, memory usage, and status of each process.

The basic syntax for the docker top command is as follows:

docker top CONTAINER [ps OPTIONS]        
docker top container-ID

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

==> The docker save command is used to save a Docker image to a tar archive. This can be useful for backing up an image, transferring it to another machine, or using it with other Docker tools.

The basic syntax for the docker save command is as follows:

docker save [OPTIONS] IMAGE [IMAGE...]        

Saving a Single Image

To save a single image to a tar archive, you can use the following command:

docker save my-image > my-image.tar        
docker save nginx > backup-of-nginx.tar

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

==> The docker load command is used to load a Docker image from a tar archive. This is useful for importing images that you have saved or exported from another machine.

The basic syntax for the docker load command is as follows:

docker load [OPTIONS] [FILE]...        

Loading an Image from a Tar Archive

To load an image from a tar archive, you can use the following command:

docker load < my-image.tar  

OR

docker load -i my-image.tar        
docker load < backup-of-nginx.tar

I hope you find the blog/article helpful.

??????? #DevOps #container#Automation #CloudServices #docker

#90daysofdevops?#90dayslearningchallenge?#90days?#devops?#devopsengineer?#devopscommunity?#development?#awsdevops??#trainwithshubham?#docker

Thanks for reading and happy learning! ??

要查看或添加评论,请登录

Prakash Bohara的更多文章

社区洞察

其他会员也浏览了