Day 16 of #90DaysOfDevOps

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:

docker run hello-world

Output:

This displayed a welcome message confirming that Docker is running.


2. Inspect a Container or Image

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

Command:

docker inspect <container_id_or_image_name>

Output:

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


3. List Port Mappings

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

Command:

docker port <container_name_or_id>

Output:

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


4. View Resource Usage Statistics

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

Command:

docker stats

Output:

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


5. View Running Processes

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

Command:

docker top <container_name_or_id>

Output:

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


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:

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

Output:

The image was successfully exported as a .tar file.


7. Load an Image from a TAR Archive

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

Command:

docker load -i <input_file.tar>

Output:

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


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


Stay Connected

I’m documenting my #90DaysOfDevOps journey to share insights and inspire others to explore DevOps. Let’s connect!
LinkedIn