Skip to main content

Command Palette

Search for a command to run...

Day 18 : Docker for DevOps Engineers

Published
2 min read
Day 18 : Docker for DevOps Engineers
S

"Passionate about simplifying the complexities of DevOps, I bring 5 years of hands-on experience in supporting development and operations teams to achieve faster, more reliable software delivery. I thrive on optimizing CI/CD pipelines, automating workflows, and troubleshooting challenges across diverse cloud environments. My expertise spans across infrastructure management, continuous integration, and performance monitoring—ensuring stability and efficiency at every stage of the software lifecycle. Always eager to learn, collaborate, and innovate, I’m committed to driving impactful change in the DevOps space."

Docker Compose:

  • Docker Compose is a tool that was developed to help define and share multi-container applications.

  • With Compose, we can create a YAML file to define the services and, with a single command, spin everything up or tear it all down.

  • Learn more about Docker Compose here.

What is YAML?

  • YAML is a data serialization language that is often used for writing configuration files. Depending on whom you ask, YAML stands for "Yet Another Markup Language" or "YAML Ain’t Markup Language" (a recursive acronym), which emphasizes that YAML is for data, not documents.

  • YAML is a popular programming language because it is human-readable and easy to understand.

  • YAML files use a .yml or .yaml extension.

  • Read more about it here.

Tasks with Answers

Task 1

Learn how to use the docker-compose.yml file to set up the environment, configure the services and links between different containers, and also to use environment variables in the docker-compose.yml file.

Task 2

  • 1. Pull a pre-existing Docker image from a public repository (e.g. Docker Hub) and run it on your local machine. Run the container as a non-root user (Hint: Use the usermod command to give the user permission to Docker). Make sure you reboot the instance after giving permission to the user.

  • Pull the Docker image:

  • Answer:

  • Add the current user to the Docker group:

Answer

  • Reboot the machine to apply the changes:

  • Run the Docker container:

2. Inspect the container's running processes and exposed ports using the docker inspect command.

  • Inspect the container:

Answer

3. Use the docker logs command to view the container's log output.

  • View the logs:

Answer

4. Use the docker stop and docker start commands to stop and start the container.

  • Stop the container:

Answer

  • Start the container:

5. Use the docker rm command to remove the container when you're done.

  • Remove the container:

Answer

Conclusion 🎯

Docker Compose and YAML work hand-in-hand to make multi-container applications easy to define, configure, and run. With Compose, you can focus on building your app, while YAML provides a clear, simple way to manage the complex interactions between containers. Whether you're developing locally or deploying to the cloud, Docker Compose is an invaluable tool for modern application development. 🌍🚀

Happy containerizing! 👩‍💻👨‍💻

"The DevOps Insight and Learning with Shivani"

Part 6 of 22

"DevOps Insight with Shivani" is a beginner-friendly series exploring DevOps tools, practices, and concepts like CI/CD pipelines. Join me for easy tutorials, practical tips, and industry updates to help you learn and grow in the DevOps world.

Up next

Day 17 Answers: Docker Project for DevOps Engineers

Dockerfile: Docker is a tool that makes it easy to run applications in containers. Containers are like small packages that hold everything an application needs to run. To create these containers, developers use something called a Dockerfile. A Docke...

More from this blog

T

The DevOps Insight with Shivani

23 posts