Day 20 Task : Docker compose

Manasa JManasa J
2 min read

Docker Compose is a tool that allows you to define and manage multi-container Docker applications using a simple YAML file called docker-compose.yml. With Docker Compose, you can easily set up, run, and manage complex applications involving multiple services like web servers, databases, caches, and more, all configured in one place.

Key Features of Docker Compose

  1. Multi-Container Deployment: Define multiple services (containers) that make up your application in a single YAML file.

  2. Networking: Automatically creates networks for your containers, allowing them to communicate with each other easily.

  3. Volumes: Manage data persistence by defining volumes for your containers.

  4. Environment Management: Easily set environment variables for your containers, making configuration management straightforward.

  5. Scaling Services: Easily scale services up or down with a single command.

Basic Docker Compose Workflow

  1. Define Your Application in docker-compose.yml: Create a YAML file that specifies your services, networks, and volumes.

  2. Build and Start Services: Use Docker Compose commands to build, start, stop, and manage your services.

Now lets create a docker compose

Step 1: Install docker compose in your system as shown in the below image

Step 2 : Here we are taking the code from github .

Step 3 : Here we have docker-compose.yaml where we will write the yaml file to build and run the docker conatiner at a time.

Step 4 : The docker-compose build command is used to build Docker images specified in your docker-compose.yml file. This command reads the build configurations, such as Dockerfiles and contexts, and creates Docker images for the services defined in the file.

Step 5:The docker-compose up command is used to start and run the services defined in your docker-compose.yml file. This command builds (if necessary), creates, and starts the containers as per the configurations specified in the Compose file. It's one of the most common and powerful commands in Docker Compose, enabling you to quickly spin up your entire application stack.

Step 6 :The docker-compose ps command provides a snapshot of the current status of the containers defined in your docker-compose.yml file. It helps you see which containers are running, their names, and their ports.

Step 7:The docker-compose logs command is used to view the logs for services defined in your docker-compose.yml file. This command provides real-time or historical log data from your containers, which is essential for debugging and monitoring the behavior of your applications.

THANK YOU FOR READING!

Do follow me on LinkedIn for further blogs.

linkedin.com/in/manasa-j-03b633238

0
Subscribe to my newsletter

Read articles from Manasa J directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Manasa J
Manasa J