Docker for DevOps Engineers

Docker for DevOps Engineers

Docker Compose:-

Docker Compose is a tool for defining and running multi-container Docker applications. It allows you to define a multi-container application using a YAML file, and then use a single command to start and manage all the containers that make up your application.

Docker Compose simplifies the process of managing complex applications that consist of multiple interconnected containers.

Here are some key features and concepts related to Docker Compose:

  1. Docker Compose YAML file: To define your multi-container application, you create a docker-compose.yml file. This file specifies the services, networks, and volumes that make up your application, along with their configuration settings.

  2. Services: In a Docker Compose file, a "service" is a container that represents a specific component of your application, such as a web server, a database, or an application server. You can define multiple services in the docker-compose.yml file, and each service has its own configuration settings, including the base image, environment variables, ports, and more.

  3. Networking: Docker Compose creates a default network for your application, and services within the same docker-compose.yml file can communicate with each other using service names as hostnames. You can also define custom networks to control the communication between services.

  4. Volumes: Volumes can be used to persist data generated by containers. Docker Compose allows you to define named volumes and bind mounts, which are used to store and share data between containers or with the host system.

  5. Up and down: Docker Compose provides commands like docker-compose up to start the defined services and docker-compose down to stop and remove the containers associated with your application.

  6. Scaling: You can scale services defined in your docker-compose.yml file using the docker-compose up --scale option to create multiple instances of a service.

  7. Environment variables: Docker Compose allows you to specify environment variables for your services, which can be used to customize container behaviour or configuration.

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.

Today's Task:-

  • 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 instance after giving permission to 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.

Day 18 of #90daysofDevOps

Thanks for reading

Follow me for more about DevOps♾️........

________________________________________________________________________________

#90daysHardChallenge

#Cloudcomputing

#DevOps

#Python

#TrainWithShubham