Day 18 : Docker Containerization for DevOps.

Day 18 : Docker Containerization for DevOps.

Today I have covered Docker-Compose where I have explained how to connect MongoDB and Mongo-Express using a YAML file.

Till now you have created a Docker-Compose file and pushed it to the Repository. Let's move forward and dig more into other Docker concepts.


What is Docker Compose?

  • Docker Compose is a tool that allows you to define and run multi-container Docker applications.

  • It is a tool for defining and running multi-container Docker applications, using a YAML file to configure the application's *services, networks, and volumes.

  • With Docker Compose, you can easily configure and run multiple containers as a single application, making it easier to manage and deploy complex applications.

  • Docker Compose is often used for developing and testing applications locally, as it allows you to define and run an entire application stack on a single machine.

  • It also makes it easy to share your application's configuration with other developers, as the configuration is stored in a single YAML file that can be committed to version control.

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.

Steps to create Docker-Compose.yaml file :

Step 1: Version (Version of Docker Compose).

Step 2: Services (Where we add containers)

Eg.(Containers,images,port,environments)

Step 3: We can create multiple environments like this.


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.

Screenshot from 2023-03-31 19-56-40


Task-2:

Pull a pre-existing Docker image from a public repository (e.g. Docker Hub) and run it on your local machine.


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

docker inspect <container_id>or<image_id>


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

docker log <container_id>

Screenshot from 2023-03-31 20-24-23


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

To stop the docker container docker stop <container_id>or<image_id>

Screenshot from 2023-03-31 20-26-07

Screenshot from 2023-03-31 20-25-09

To start the docker container docker start <container_id>or<image_id>

Screenshot from 2023-03-31 20-26-17

Screenshot from 2023-03-31 20-26-39


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

docker rm <container_id>or<image_id>

Screenshot from 2023-03-31 20-40-39


Happy Learning :)

Did you find this article valuable?

Support DevOps by becoming a sponsor. Any amount is appreciated!