Day 18 : Docker for DevOps Engineers

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, can spin everything up or tear it all down.

What is YAML?

  • YAML is a human-readable data serialization language used for configuration files and data exchange. It's not a markup language but is designed for representing structured data in a simple and readable format.

  • YAML files use a .yml or .yaml extension.

How to run Docker commands without sudo?

  • Make sure docker is installed and system is updated (This is already been completed as a part of previous tasks):

  • sudo usermod -a -G docker $USER

  • Reboot the machine.

Task-1:

Docker-compose:

  1. Install Docker Compose if not already done.

  1. Create a new project directory.

  2. Create a YAML file (usually named docker-compose.yml) in the project directory.

  1. Use docker-compose up to start your services based on the YAML file.

Task-2:

  1. 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 user permission to docker). Make sure you reboot instance after giving permission to user.

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

    To inspect a container's running processes and exposed ports using the docker inspect command, you can follow these steps:

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

To view a container's log output using the docker logs command, simply run the following command:

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

To stop a container:

docker stop CONTAINER_ID_OR_NAME

To start a container:

docker start CONTAINER_ID_OR_NAME

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

To remove a Docker container when you're done with it, use the following command:

Before removing container , one needs to stop that container.

Thank you for reading :-)

Priyanka varshney

0
Subscribe to my newsletter

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

Written by

priyanka varshney
priyanka varshney

๐Ÿ‘‹ Hello, and welcome to my DevOps journey! ๐Ÿš€ I am Priyanka Varshney,๐Ÿ› ๏ธ As an aspiring DevOps engineer, I'm all about bridging the gap between development and operations, making software delivery seamless and efficient. ๐Ÿ’ป๐Ÿ”ง On this Hashnode blog, I'll be sharing my learnings, experiences and adventures as I dive deep into the world of continuous integration, automation, and cloud technologies. โ˜๏ธโš™๏ธ Let's connect, learn, and grow as a vibrant DevOps community. Follow my Hashnode blog, and let's embrace the DevOps adventure together! ๐Ÿค๐Ÿ”—