Day 16 🐳Docker for DevOps Engineers🚀

Hi there! I'm Fauzeya 👩💻, a passionate DevOps Engineer with a background in Computer Science Engineering🎓. I’m committed to enhancing security🔒, efficiency⚙️, and effectiveness in software development and deployment processes. With extensive knowledge in cloud computing☁️, containerization📦, and automation🤖, I aim to stay updated with the latest tools and methodologies in the DevOps field. Currently, I’m on a journey to deepen my understanding of DevOps I enjoy sharing my learning experiences and insights through my blog, 📝where I cover topics related to DevOps practices, tutorials, and challenges. I believe in continuous growth and learning and am excited to connect with fellow tech enthusiasts and professionals🤝. Let’s embark on this journey together!🚀
Docker is a platform for building, testing, and deploying applications in standardized units called containers. Each container includes all necessary libraries, tools, and code, ensuring the application runs consistently across environments. This makes deployment fast, scalable, and reliable, solving "it works on my machine" issues and supporting seamless DevOps workflows.

Docker's architecture is composed of three main components
Docker’s architecture brings together three key components that collaborate to enable efficient containerized application deployment and management:
Docker Client: This is the user interface (CLI or GUI) for interacting with Docker, allowing users to issue commands
docker runto build, manage, and operate containers. The client communicates with the Docker Host to carry out these actions.Docker Host: This is where the Docker Daemon (dockerd) runs, managing Docker Objects such as images, containers, networks, and volumes. It provides the necessary system resources to execute containers and maintain their lifecycle. The Docker Host pulls images from the Docker Registry to create containers.
Docker Registry: A centralized repository for Docker images, where images are stored, versioned, and shared. Popular options include Docker Hub (public) and private registries, which enable image sharing across teams or projects. The Docker Host can pull images from or push images to the registry, facilitating easy distribution and version control.
Together, these components ensure that Docker containers are portable, scalable, and consistent across any environment, making Docker a powerful tool for modern DevOps workflows.
1. Run a New Container
To start a new container using the docker run command, you can use the hello-world image to verify your Docker installation:
docker run hello-world
- What It Does: This command runs the
hello-worldimage. If Docker is installed correctly, you should see a message confirming that Docker is working.
2. Inspect a Container or Image
To view detailed information about a specific container or image, use the docker inspect command. Replace [container_id] with the actual ID or name of your container:
docker inspect [container_id]
- What It Does: This command provides detailed information in JSON format about the specified container or image, including configurations, state, and network settings.
3. List Port Mappings for a Container
To view the port mappings for a specific container, use the docker port command. Replace [container_id] with the actual ID or name of your container:
docker port [container_id]
- What It Does: This command shows the port mappings for the specified container, allowing you to see which ports on the host machine correspond to the container’s ports.
4. View Resource Usage Statistics
To view resource usage statistics for all running containers, use the docker stats command:
docker stats
- What It Does: This command provides real-time statistics about CPU usage, memory usage, network I/O, and other metrics for each running container.
5. View Processes Running Inside a Container
To see the processes running inside a specific container, use the docker top command. Replace [container_id] with the actual ID or name of your container:
docker top [container_id]
- What It Does: This command shows the running processes inside the specified container, including process IDs and commands.
6. Save an Image to a Tar Archive
To save a Docker image to a tar archive, use the docker save command. Replace [image_name] with the name of the image you want to save and [archive_name].tar with your desired archive name:
docker save -o [archive_name].tar [image_name]
- What It Does: This command saves the specified Docker image to a tar file, which can be used for backup or transfer.
7. Load an Image from a Tar Archive
To load a Docker image from a tar archive, use the docker load command:
docker load -i [archive_name].tar
- What It Does: This command loads a Docker image from the specified tar file back into your Docker environment.
Summary of Commands
Here's a quick summary of the commands you'll be using:
| Command | Description |
docker run hello-world | Start a new container with the hello-world image. |
docker inspect [container_id] | View detailed information about a container or image. |
docker port [container_id] | List the port mappings for a specific container. |
docker stats | View resource usage statistics for running containers. |
docker top [container_id] | View processes running inside a specified container. |
docker save -o [archive_name].tar [image_name] | Save an image to a tar archive. |
docker load -i [archive_name].tar | Load an image from a tar archive. |
Summary: Docker is a platform that lets developers build, test, and deploy applications quickly using containers 🧳. Each container has everything needed to run an app: code, libraries, dependencies, and configurations, ensuring it works reliably across any environment 🌍.




