Skip to main content

Command Palette

Search for a command to run...

Day 18 : Mastering Docker Compose: A Comprehensive Guide for DevOps Engineers πŸš€

Published
β€’2 min readβ€’View as Markdown
Day 18 : Mastering Docker Compose: A Comprehensive Guide for DevOps Engineers πŸš€
A

"I'm a 3rd-year Computer Engineering student at Marwadi University with skills in C++, web development (MERN stack), and DevOps tools like Kubernetes. I contribute to open-source projects and share tech knowledge on GitHub and LinkedIn. I'm learning cloud technologies and app deployment. As an Internshala Student Partner, I help others find jobs and courses." now currently focusing on #90DaysOfDevops

Till now you have created a Dockerfile and pushed it to the repository. Let's move forward and dig deeper into other Docker concepts. Today, let's study Docker Compose! πŸ˜ƒ

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.

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.

Sample docker-compose.yml file

Task 2

  • 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.

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

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

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

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

  1. Pulling a pre-existing Docker image from a public repository.

  1. Running it on your local machine.

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

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

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

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

How to Run Docker Commands Without Sudo?

  • Make sure Docker is installed and the system is updated (This was already completed as part of previous tasks):

  • sudo usermod -a -G docker $USER

  • Reboot the machine.

Thank you for reading!

Β© 2024 Anand Raval. All rights reserved.

90DaysOfDevops

Part 29 of 49

So In This Series I am following 90 DaysOfDevops challenge , what i will learn in my devops journey i will share with you with my blogs ,You will get blog on tools which used by devops engineer , example :- Linux,ansible,terraform,docker,etc

Up next

Day 17 : Docker Project for DevOps Engineers

Day 17 Task: 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 Dockerfi...

More from this blog

A

Anand Raval

146 posts

I'm Anand Raval, a Cloud & DevOps Engineer with AWS Solutions Architect Associate (SAA-C03), Certified Kubernetes Administrator (CKA), and Azure Fundamentals (AZ-900) certifications. This blog covers AWS, Kubernetes, Terraform, CI/CD, cloud architecture, automation, cost optimization, troubleshooting guides, and hands-on DevOps projects.