Day 16 : Docker for DevOps Engineers

Day 16 : Docker for DevOps Engineers

Introduction to Docker :

Docker is an open-source platform that automates the deployment of applications in lightweight, portable containers. Containers encapsulate everything required to run a piece of software, including code, runtime, libraries, and system tools, making them consistent and reliable across different environments.

Before we dive into the Docker commands, let’s ensure you have Docker installed.

1. Using the docker run Command

The docker run command is your entry point into the world of Docker. It allows you to start a new container and interact with it through the command line. To get started, you can use the classic "Hello World" example.

docker run hello-world

This command pulls the hello-world image from Docker Hub and runs it in a new container. You'll see a friendly message confirming that Docker is up and running.

2. Using the docker inspect Command

The docker inspect command provides detailed information about a container or image. You can use it to retrieve various attributes, including network settings, environment variables, and more.

For example, to inspect a running container:

docker inspect container_name_or_id

3. Using the docker port Command

The docker port command lists the port mappings for a container. It helps you quickly identify the ports that are exposed and mapped between the container and the host system.

docker port container_name_or_id

4. Using the docker stats Command

The docker stats command gives you real-time resource usage statistics for one or more containers. This is particularly useful for monitoring the performance of your containers.

docker stats container_name_or_id

5. Using the docker top Command

The docker top command allows you to view the processes running inside a container. This gives you insights into what is happening within the container's isolated environment.

docker top container_name_or_id

6. Using the docker save Command

The docker save command lets you save an image to a tar archive. This is helpful when you want to share images with others or move them between environments.

docker save -o image.tar image_name

7. Using the docker load Command

The docker load command is used to load an image from a tar archive. This is the counterpart to the docker save command.

docker load -i image.tar

Thank you for taking the time to read !