Docker for DevOps Engineers part-III

Suraj barikSuraj barik
2 min read

Docker🦈 Compose:

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

  • Spin your application up in a single command

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

Install Docker Compose

sudo apt-get update
#install docker first
sudo apt-get install docker.io -y
#give acess user to acess docker
sudo usermod -a -G docker $USER 
#reboot the system
sudo reboot

Now, Install docker-compose

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.

Assessment

✔Task-1

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

Create a docker-compose.yaml file

vim docker-compose.yaml

Then run docker-compose.yaml file

✔Task-2

  1. Pll 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 giving permission to the user.

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

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

  4. 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. To pull pre-existing docker image, you first need to login to your docker hub registry

    1. Pulling a custom image from docker hub using the command:

      docker pull repository_name/image_name:tag

      1. 6Created container from the image

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

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

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

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

Thank you for reading. Happy Learning 😊

0
Subscribe to my newsletter

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

Written by

Suraj barik
Suraj barik

I'm Suraj Barik Aspiring DevOps Engineer with Hands-on experience in Automating,Shell Scripting, Supporting in AWS, management, CI/CD, and DevOps processes.