Docker Compose: Docker for DevOps Engineers

Docker Compose: Docker for DevOps Engineers

#Day 18 of 90daysofdevops

Docker Compose

Docker compose is a tool for defining and running multi-container docker applications using a yaml file.

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

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.

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.

root@ip-172-31-90-171:~# docker-compose up -d

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 usermod command to give the user permission to docker). Make sure you reboot the instance after permitting 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.

    docker stop <container id>command is used to stop the container.

    root@ip-172-31-90-171:~# docker stop 5af7b5889457

docker start <container id > This command is used to start the container.

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

    We can remove the container by using the docker rm command. Here I will stop the container and then I will remove it. Please refer screenshot.

Thank you for reading this blog.Happy Learning!!!!!

You can follow me on LinkedIn for my daily updates:- linkedin.com/in/parimal-pradhan-b62021168

Great initiative by the #trainwithshubham community. Thank you Shubham Londhe

Did you find this article valuable?

Support Parimal Pradhan by becoming a sponsor. Any amount is appreciated!