# Day 16 of #90DaysOfDevOps

---

# Docker for DevOps Engineers

As part of my #90DaysOfDevOps challenge, today’s focus was on mastering essential Docker commands. Docker is a vital tool in the DevOps toolkit, enabling seamless containerization and environment consistency for applications. Here’s what I learned and implemented.

---

## What is Docker?

Docker is a platform that allows developers to build, test, and deploy applications in a consistent environment called containers. Containers package everything needed for the application to run—libraries, system tools, code, and runtime—making it highly portable and scalable across different environments.

### Why is Docker Important for DevOps?

* **Consistency:** Containers ensure applications run the same way across development, staging, and production.
    
* **Scalability:** Quickly deploy and scale applications in any environment.
    
* **Efficiency:** Reduces resource usage compared to traditional virtual machines.
    

---

## Docker Commands I Practiced Today

Here are the commands I learned and their applications:

### 1\. **Run a Docker Container**

Using the `docker run` command, I started a basic container to verify Docker installation and functionality.

#### Command:

```bash
docker run hello-world
```

#### Output:

This displayed a welcome message confirming that Docker is running.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1734764833415/5ca97d97-8259-4d7a-9491-09e787f9560d.png align="center")

---

### 2\. **Inspect a Container or Image**

With `docker inspect`, I explored detailed metadata about containers and images.

#### Command:

```bash
docker inspect <container_id_or_image_name>
```

#### Output:

This command provided in-depth JSON-formatted information, including network settings and configurations.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1734764842666/6cdb6338-d478-4188-a354-928812a6ccde.png align="center")

---

### 3\. **List Port Mappings**

Using the `docker port` command, I viewed port mappings for a running container.

#### Command:

```bash
docker port <container_name_or_id>
```

#### Output:

The command displayed the mappings between the container’s internal ports and the host’s ports.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1734764850442/2fe1bc26-bec7-474b-a30e-b74e196fbedc.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1734764857011/69df2192-fef8-4884-a8a0-67e0c8485377.png align="center")

---

### 4\. **View Resource Usage Statistics**

The `docker stats` command helped me monitor resource usage in real-time.

#### Command:

```bash
docker stats
```

#### Output:

This provided live statistics on CPU, memory, and network usage for containers.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1734764877347/5ef5935d-29bd-42ee-b261-3221de774f83.png align="center")

---

### 5\. **View Running Processes**

Using `docker top`, I listed processes running inside a container.

#### Command:

```bash
docker top <container_name_or_id>
```

#### Output:

It displayed the processes, including their PID, user, and command.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1734764887223/542baa3b-5243-4a7c-88c4-5109a6734a18.png align="center")

---

### 6\. **Save an Image to a TAR Archive**

With `docker save`, I saved a Docker image to a file for backup or transfer purposes.

#### Command:

```bash
docker save -o <output_file.tar> <image_name>
```

#### Output:

The image was successfully exported as a `.tar` file.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1734764895400/7e476f07-60c4-4c1d-929d-8a16b08553af.png align="center")

---

### 7\. **Load an Image from a TAR Archive**

Finally, I used `docker load` to import a previously saved Docker image.

#### Command:

```bash
docker load -i <input_file.tar>
```

#### Output:

The image was successfully re-imported into my local Docker setup.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1734764903619/62a7d758-df72-423a-96ce-a52ef3e580ec.png align="center")

---

## Key Takeaways

* Docker simplifies application deployment and ensures consistency across environments.
    
* Commands like `docker run`, `docker stats`, and `docker save` are fundamental for container management.
    
* Hands-on practice with Docker is crucial for understanding its potential in DevOps workflows.
    

---

## Additional Resources

To dive deeper into Docker commands, I recommend watching this helpful video:  
[Docker Basics for Beginners](https://youtu.be/Tevxhn6Odc8)

---

## Stay Connected

I’m documenting my #90DaysOfDevOps journey to share insights and inspire others to explore DevOps. Let’s connect!  
[LinkedIn](https://www.linkedin.com/in/amitabh-devops/)

---
